MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / load_identity_or_default

Function load_identity_or_default

atomic-cli/src/commands/identity/mod.rs:472–493  ·  view source on GitHub ↗

Load a named identity, or the store default when no name is given. The one place that decides what "no `--identity`" means, so the agent commands cannot drift from the rest of the CLI on it.

(
    store: &atomic_identity::IdentityStore,
    name: Option<&str>,
)

Source from the content-addressed store, hash-verified

470/// The one place that decides what "no `--identity`" means, so the agent
471/// commands cannot drift from the rest of the CLI on it.
472pub fn load_identity_or_default(
473 store: &atomic_identity::IdentityStore,
474 name: Option<&str>,
475) -> crate::error::CliResult<atomic_identity::Identity> {
476 use crate::error::CliError;
477 match name {
478 Some(name) => store
479 .load_by_name(name)
480 .map_err(|_| CliError::IdentityNotFound(name.to_string())),
481 None => store
482 .get_default()
483 .map_err(|e| {
484 CliError::Internal(anyhow::anyhow!("Failed to load default identity: {e}"))
485 })?
486 .ok_or_else(|| {
487 CliError::Internal(anyhow::anyhow!(
488 "No default identity set. Create one first:\n \
489 atomic identity new <name> --email <email> --set-default"
490 ))
491 }),
492 }
493}
494
495/// Record an agent identity on a server profile so hooks use it by default.
496///

Callers 2

runMethod · 0.85
revoke_everythingMethod · 0.85

Calls 2

load_by_nameMethod · 0.80
get_defaultMethod · 0.45

Tested by

no test coverage detected