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>,
)
| 426 | /// `None` (not provided → fall back to default) from `Some("")` (provided |
| 427 | /// empty → error) prevents a class of confusing bugs. |
| 428 | pub fn resolve_workspace( |
| 429 | org_slug: &str, |
| 430 | workspace_override: Option<&str>, |
| 431 | server_override: Option<&str>, |
| 432 | ) -> CliResult<String> { |
| 433 | if let Some(s) = workspace_override { |
| 434 | if s.is_empty() { |
| 435 | return Err(CliError::InvalidArgument { |
| 436 | message: "Workspace slug cannot be empty.".to_string(), |
| 437 | }); |
| 438 | } |
| 439 | return Ok(s.to_string()); |
| 440 | } |
| 441 | |
| 442 | let config = GlobalConfig::load() |
| 443 | .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load global config: {}", e)))?; |
| 444 | |
| 445 | let (server, _name) = config |
| 446 | .resolve_server(server_override) |
| 447 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 448 | |
| 449 | resolve_workspace_with_server(org_slug, None, server) |
| 450 | } |
| 451 | |
| 452 | /// Resolve a flexible identity reference to a UUID. |
| 453 | /// |