MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / resolve_workspace

Function resolve_workspace

atomic-cli/src/commands/client.rs:428–450  ·  view source on GitHub ↗

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>,
)

Source from the content-addressed store, hash-verified

426/// `None` (not provided → fall back to default) from `Some("")` (provided
427/// empty → error) prevents a class of confusing bugs.
428pub 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///

Callers 6

project_initFunction · 0.85
runMethod · 0.85
executeMethod · 0.85
runMethod · 0.85

Calls 3

resolve_serverMethod · 0.80
is_emptyMethod · 0.45