Resolve the workspace slug for a command, with fallback to the org-scoped default workspace from the **active** server profile. Loads global config, resolves the active server profile (honouring `server_override` → `default_server` → legacy `[server]`), and delegates to [`resolve_workspace_with_server`]. This keeps reads aligned with `atomic workspace set`, which writes into that same active prof
(
org_slug: &str,
workspace_override: Option<&str>,
server_override: Option<&str>,
)
| 425 | /// `None` (not provided → fall back to default) from `Some("")` (provided |
| 426 | /// empty → error) prevents a class of confusing bugs. |
| 427 | pub fn resolve_workspace( |
| 428 | org_slug: &str, |
| 429 | workspace_override: Option<&str>, |
| 430 | server_override: Option<&str>, |
| 431 | ) -> CliResult<String> { |
| 432 | if let Some(s) = workspace_override { |
| 433 | if s.is_empty() { |
| 434 | return Err(CliError::InvalidArgument { |
| 435 | message: "Workspace slug cannot be empty.".to_string(), |
| 436 | }); |
| 437 | } |
| 438 | return Ok(s.to_string()); |
| 439 | } |
| 440 | |
| 441 | let config = GlobalConfig::load() |
| 442 | .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load global config: {}", e)))?; |
| 443 | |
| 444 | let (server, _name) = config |
| 445 | .resolve_server(server_override) |
| 446 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 447 | |
| 448 | resolve_workspace_with_server(org_slug, None, server) |
| 449 | } |
| 450 | |
| 451 | /// Resolve a flexible identity reference to a UUID. |
| 452 | /// |