migrate mail config from ~/.myclaude to ~/.config/mytoolkit
This commit is contained in:
+18
-3
@@ -15,15 +15,30 @@ import click
|
|||||||
|
|
||||||
from bin.utils import handle_errors
|
from bin.utils import handle_errors
|
||||||
|
|
||||||
CONFIG_PATH = Path.home() / ".myclaude" / "mail.json"
|
OLD_CONFIG_PATH = Path.home() / ".myclaude" / "mail.json"
|
||||||
|
CONFIG_PATH = Path.home() / ".config" / "mytoolkit" / "mail.json"
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_config_path() -> Path:
|
||||||
|
"""Return active config path, migrating from old location if needed."""
|
||||||
|
if CONFIG_PATH.exists():
|
||||||
|
return CONFIG_PATH
|
||||||
|
if OLD_CONFIG_PATH.exists():
|
||||||
|
CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
import shutil
|
||||||
|
shutil.copy2(OLD_CONFIG_PATH, CONFIG_PATH)
|
||||||
|
click.echo(f"Migrated config: {OLD_CONFIG_PATH} -> {CONFIG_PATH}")
|
||||||
|
return CONFIG_PATH
|
||||||
|
return CONFIG_PATH
|
||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
"""Load mail config."""
|
"""Load mail config."""
|
||||||
if not CONFIG_PATH.exists():
|
path = _resolve_config_path()
|
||||||
|
if not path.exists():
|
||||||
click.echo("Mail not configured. Run: mytoolkit mail config", err=True)
|
click.echo("Mail not configured. Run: mytoolkit mail config", err=True)
|
||||||
raise click.Abort()
|
raise click.Abort()
|
||||||
with open(CONFIG_PATH, encoding="utf-8") as f:
|
with open(path, encoding="utf-8") as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user