Skip to content

refactor(cli): extract load_creds_or_login_hint helper #13

Description

@I-am-nothing

Surfaced during /simplify on #11.

`src/commands/whoami.rs:20-28` and `src/commands/module.rs:66-74` both do:

```rust
let creds = match credentials::load() {
Ok(c) => c,
Err(LoadError::NotFound) => {
return Err(anyhow!("not signed in. Run `mirrorstack login` to sign in."));
}
Err(e) => return Err(e.into()),
};
```

Extract a helper in `src/credentials/mod.rs` (or `src/commands/mod.rs`):

```rust
pub fn load_or_login_hint() -> anyhow::Result
```

Use from both call sites. Any future command that needs auth gets the same hint for free.

Why skipped from #11

That PR's scope was the three user-visible bugs (404 routing, missing pre-flight, plain-text UX). This is a small cross-file dedup — better as its own change so the diff stays readable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions