Skip to content

Multiple accounts via suffixed env vars - #4

Merged
thepeak99 merged 1 commit into
masterfrom
feat/multi-account
Jul 9, 2026
Merged

Multiple accounts via suffixed env vars#4
thepeak99 merged 1 commit into
masterfrom
feat/multi-account

Conversation

@thepeak99

Copy link
Copy Markdown
Member

What

Adds multiple-account support to mail-cli, staying fully env-only and stateless. Each account is a set of MAILCLI_* env vars sharing a suffix (_1, _2, …); a single run targets one account.

mail-cli list                 # default account = bare MAILCLI_* vars (unchanged)
mail-cli --account 1 list     # reads MAILCLI_*_1
mail-cli accounts             # discover configured accounts (never prints passwords)

Design

  • Selection precedence: --account <TOKEN> (global flag) > MAILCLI_ACCOUNT env > none.
  • No --account → the default account = the bare, un-suffixed vars → zero breakage for existing setups.
  • Token is numeric by convention but any non-empty string works (one code path); empty token rejected loudly.
  • Strict, no fallback: account N is read only from *_N; a miss fails naming the exact var (e.g. required environment variable MAILCLI_PASSWORD_2 is not set).
  • Config values stay env-only; the runtime choice of account is a CLI flag — consistent with the repo's boundary rule. All env reading stays in config.rs.

Changes

  • config.rsEnv { suffix } resolver (name-building at the boundary) + from_env(&Env); scan_accounts()/AccountInfo for discovery (emits has_password presence only, never the value).
  • main.rs — global --account flag; new accounts subcommand; &Env threaded into connecting commands. install-skill untouched.
  • output.rsaccounts_human table (ok/incomplete, no secrets).
  • Docs — README "Multiple accounts" section + accounts; AGENTS.md security rule.
  • SkillSKILL.md + references/reference.md (AccountInfo schema) + 2 new evals; verified install-skill --force output is byte-identical to skill/.
  • ACCOUNTS-PLAN.md — locked design doc (mirrors the repo's plan-doc convention).

Tests / CI

  • +11 config.rs unit tests: name resolution, empty-token reject, suffixed-error naming, scanner (default+numeric, incomplete-no-leak, sort order, empty-value skip).
  • 45 tests pass (16 lib + 26 bin + 3 integration).
  • Ran the exact CI checks locally: cargo fmt --all -- --check, cargo clippy --all-targets --locked -- -D warnings, cargo test --locked — all green.

Co-authored by PeakBot!

@thepeak99
thepeak99 force-pushed the feat/multi-account branch from c1e2c27 to 2f2e37a Compare July 9, 2026 07:40
Configure several accounts at once with MAILCLI_*_<N> env vars and select
one per invocation with a global --account flag. Omitting --account uses
the bare, un-suffixed vars (the "default" account), so existing setups are
unchanged.

- config.rs: Env{suffix} resolver (name-building at the boundary), strict
  no-fallback reads, from_env(&Env). Add scan_accounts()/AccountInfo for
  discovery (never exposes the password value).
- main.rs: global --account flag (flag > MAILCLI_ACCOUNT env > default),
  new `accounts` subcommand; thread &Env into connecting commands.
- output.rs: accounts_human table (ok/incomplete status, no secrets).
- Docs: README "Multiple accounts" section + accounts cmd; AGENTS.md rule.
- Skill: SKILL.md + reference.md (AccountInfo schema) + 2 new evals;
  install-skill output verified byte-identical to skill/.
- plans/: local git-ignored dir for working design docs (kept in the repo
  by its own tracked .gitignore); the ACCOUNTS-PLAN doc lives here.

Tests: +11 config unit tests (name resolution, empty-token reject,
suffixed-error naming, scanner + no-leak + sort). 45 tests pass; clippy
-D warnings clean; fmt clean.

Co-authored by PeakBot!
@thepeak99
thepeak99 force-pushed the feat/multi-account branch from 2f2e37a to edd72d9 Compare July 9, 2026 07:42
@thepeak99
thepeak99 merged commit 269881f into master Jul 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant