(&self)
| 70 | |
| 71 | impl Command for WhoAmI { |
| 72 | fn run(&self) -> CliResult<()> { |
| 73 | // Open the identity store |
| 74 | let store = IdentityStore::open_default().map_err(|e| { |
| 75 | CliError::Internal(anyhow::anyhow!("Failed to open identity store: {}", e)) |
| 76 | })?; |
| 77 | |
| 78 | // Get the appropriate default identity |
| 79 | let (identity, context) = if let Some(usage_str) = &self.usage { |
| 80 | let usage = IdentityUsage::parse(usage_str); |
| 81 | let identity = store.get_default_for_usage(&usage).map_err(|e| { |
| 82 | CliError::Internal(anyhow::anyhow!("Failed to get default identity: {}", e)) |
| 83 | })?; |
| 84 | (identity, Some(usage)) |
| 85 | } else { |
| 86 | let identity = store.get_default().map_err(|e| { |
| 87 | CliError::Internal(anyhow::anyhow!("Failed to get default identity: {}", e)) |
| 88 | })?; |
| 89 | (identity, None) |
| 90 | }; |
| 91 | |
| 92 | // Handle no identity case |
| 93 | let Some(identity) = identity else { |
| 94 | if let Some(usage) = &context { |
| 95 | print_warning(&format!("No default identity set for {} usage", usage)); |
| 96 | } else { |
| 97 | print_warning("No default identity set"); |
| 98 | } |
| 99 | println!(); |
| 100 | print_hint("Create a new identity with: atomic identity new <name> --email <email>"); |
| 101 | print_hint("Set a default with: atomic identity default <name>"); |
| 102 | return Ok(()); |
| 103 | }; |
| 104 | |
| 105 | // Output based on format |
| 106 | match self.format.to_lowercase().as_str() { |
| 107 | "json" => self.output_json(&identity, context.as_ref()), |
| 108 | _ => self.output_default(&identity, context.as_ref()), |
| 109 | } |
| 110 | |
| 111 | Ok(()) |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | impl WhoAmI { |
nothing calls this directly
no test coverage detected