remove old config compat, use ~/.config/mytoolkit only

This commit is contained in:
Zhengshou Lai
2026-04-26 10:50:40 +08:00
parent 706286a303
commit 7547053247
+2 -17
View File
@@ -15,30 +15,15 @@ import click
from bin.utils import handle_errors from bin.utils import handle_errors
OLD_CONFIG_PATH = Path.home() / ".myclaude" / "mail.json"
CONFIG_PATH = Path.home() / ".config" / "mytoolkit" / "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."""
path = _resolve_config_path() if not CONFIG_PATH.exists():
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(path, encoding="utf-8") as f: with open(CONFIG_PATH, encoding="utf-8") as f:
return json.load(f) return json.load(f)