diff --git a/restart_prompt.md b/restart_prompt.md index 5145baf..e1c0006 100644 --- a/restart_prompt.md +++ b/restart_prompt.md @@ -76,6 +76,7 @@ Scripts using shared IMAP folder handling: `verplaats_bestaand.py` current behavior: - Default mode is dry-run; real moves require `--uitvoeren` and an interactive `JA` confirmation. +- Account selection is explicit with `--account `; use `--account backup` for the disposable backup mailbox. The script prints both the config account name and mailbox address before connecting. - `--audit` is available only in dry-run mode. It suppresses per-message dry-run lines and prints planned move counts grouped by source folder and destination folder for step 2 and step 3. - IMAP `LIST`, `SELECT`, `UID SEARCH`, and `UID FETCH` aborts are logged and retried once after reconnecting. If reconnect also fails, the script records an `ABORT`/`ERROR` in `verplaats_log.json` instead of printing a Python traceback. - `MAP_RENAMES` is intentionally empty. @@ -192,7 +193,7 @@ Latest live mailbox verification: Recommended next work: -1. Ask the user to run a non-destructive dry-run sorter audit on `backup@australius.nl`, for example `python3 verplaats_bestaand.py --audit` with config pointed at the backup account, then review planned moves by source and destination. +1. Ask the user to run a non-destructive dry-run sorter audit on `backup@australius.nl`: `python3 verplaats_bestaand.py --account backup --audit`, then review planned moves by source and destination. 2. Review the audit output for suspicious high-volume destinations, missing matches, and unexpected `Afmelden.*` or invoice routes before approving any actual sorting. 3. Add shared operation helpers where useful: - UID fetch wrappers. diff --git a/verplaats_bestaand.py b/verplaats_bestaand.py index 6b341b1..ca34c0e 100644 --- a/verplaats_bestaand.py +++ b/verplaats_bestaand.py @@ -13,7 +13,8 @@ Stap 2 – Per-bericht routing: Stap 3 – Facturen per kwartaal sorteren (Facturen - te verwerken). Standaard: DRY RUN (laat zien wat er zou gebeuren, verplaatst niets). -Echt uitvoeren: python3 verplaats_bestaand.py --uitvoeren +Account kiezen: python3 verplaats_bestaand.py --account backup --audit +Echt uitvoeren: python3 verplaats_bestaand.py --account backup --uitvoeren Log: verplaats_log.json """ @@ -526,6 +527,19 @@ def load_log() -> dict: return {} +def account_name_from_args() -> str | None: + args = sys.argv[1:] + if "--account" not in args: + return None + + idx = args.index("--account") + if idx + 1 >= len(args) or args[idx + 1].startswith("--"): + print("Gebruik: python3 verplaats_bestaand.py --account [--audit|--uitvoeren]") + sys.exit(1) + + return args[idx + 1] + + # ── main ────────────────────────────────────────────────────────────────────── def run(): @@ -545,8 +559,9 @@ def run(): print("Afgebroken.") sys.exit(0) - cfg = config.load() - print(f"Account: {cfg.username}\n") + account_name = account_name_from_args() + cfg = config.load(account_name) + print(f"Account: {cfg.name} ({cfg.username})\n") print(f"Verbinden met {cfg.imap_host}:{cfg.imap_port} ...") session = ImapSession(cfg)