Resolve the org slug for a command, with fallback to the configured default. This variant uses the *active* server's `default_org` so that per-server org defaults are respected. Resolution order: 1. `--org` override (if `Some(non-empty)`) 2. `server.default_org` from the resolved server profile 3. The default identity's personal org (the identity name), so commands always target the tenant assoc
(
org_override: Option<&str>,
server: &atomic_config::ServerConfig,
)
| 316 | /// An explicit empty string (`--org ""`) is an error: the user asked for "no |
| 317 | /// org" which never makes sense. |
| 318 | pub fn resolve_org_with_server( |
| 319 | org_override: Option<&str>, |
| 320 | server: &atomic_config::ServerConfig, |
| 321 | ) -> CliResult<String> { |
| 322 | if let Some(s) = org_override { |
| 323 | if s.is_empty() { |
| 324 | return Err(CliError::InvalidArgument { |
| 325 | message: "Organization slug cannot be empty.".to_string(), |
| 326 | }); |
| 327 | } |
| 328 | return Ok(s.to_string()); |
| 329 | } |
| 330 | |
| 331 | if let Some(org) = &server.default_org { |
| 332 | return Ok(org.clone()); |
| 333 | } |
| 334 | |
| 335 | // Fall back to the personal org of the identity this server authenticates |
| 336 | // as. Registration seeds the personal org slug from the identity name, so |
| 337 | // the identity name is the correct default until the user runs |
| 338 | // `atomic org set` to switch to a team org. |
| 339 | let identity = resolve_identity_for_server(server).map_err(|_| CliError::InvalidArgument { |
| 340 | message: "No organization specified.\n \ |
| 341 | Use --org or set a default with: atomic org set <slug>" |
| 342 | .to_string(), |
| 343 | })?; |
| 344 | Ok(identity.name) |
| 345 | } |
| 346 | |
| 347 | /// Resolve the org slug for callers that don't already hold a server config. |
| 348 | /// |
no test coverage detected