Skip to content

refactor(creds): extract load_or_login_hint helper#14

Merged
I-am-nothing merged 1 commit into
mainfrom
refactor/13-creds-load-helper
May 4, 2026
Merged

refactor(creds): extract load_or_login_hint helper#14
I-am-nothing merged 1 commit into
mainfrom
refactor/13-creds-load-helper

Conversation

@I-am-nothing

Copy link
Copy Markdown
Contributor

Summary

  • New `credentials::load_or_login_hint()` wraps `load()` with the auth-required-command idiom: `NotFound` → "run `mirrorstack login`" hint instead of the raw error.
  • `whoami` and `module init` now call `load_or_login_hint()?` (a single line) instead of duplicating the 5-line NotFound match.
  • Test extends `credentials_lifecycle` to cover both the missing-file (returns hint) and present-file (returns same data as `load()`) paths. Lifecycle test is single-test by design — env-var mutation in `with_temp_config_dir` would race if split.

Test plan

  • `cargo fmt --check`
  • `cargo clippy --all-targets -- -D warnings`
  • `cargo test` — 22/22

Closes #13

\`whoami\` and \`module init\` were reimplementing the same five-line
"NotFound → login hint" match. Extracts \`credentials::load_or_login_hint\`
so each new auth-gated command is a single \`?\` instead of copy-pasting
the same error mapping.

Closes #13

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@I-am-nothing I-am-nothing merged commit f1d2bed into main May 4, 2026
5 checks 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.

refactor(cli): extract load_creds_or_login_hint helper

1 participant