migrate mail config from ~/.myclaude to ~/.config/mytoolkit

This commit is contained in:
Zhengshou Lai
2026-04-26 10:48:35 +08:00
parent 04cbd9786e
commit 706286a303
+18 -3
View File
@@ -15,15 +15,30 @@ import click
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():
"""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)
raise click.Abort()
with open(CONFIG_PATH, encoding="utf-8") as f:
with open(path, encoding="utf-8") as f:
return json.load(f)