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>,
)
| 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. |
| 472 | pub 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 | /// |
no test coverage detected