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

Function resolve_workspace

atomic-cli/src/commands/client.rs:355–377  ·  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

353/// `None` (not provided → fall back to default) from `Some("")` (provided
354/// empty → error) prevents a class of confusing bugs.
355pub fn resolve_workspace(
356 org_slug: &str,
357 workspace_override: Option<&str>,
358 server_override: Option<&str>,
359) -> CliResult<String> {
360 if let Some(s) = workspace_override {
361 if s.is_empty() {
362 return Err(CliError::InvalidArgument {
363 message: "Workspace slug cannot be empty.".to_string(),
364 });
365 }
366 return Ok(s.to_string());
367 }
368
369 let config = GlobalConfig::load()
370 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load global config: {}", e)))?;
371
372 let (server, _name) = config
373 .resolve_server(server_override)
374 .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?;
375
376 resolve_workspace_with_server(org_slug, None, server)
377}
378
379/// Resolve a flexible identity reference to a UUID.
380///

Callers 5

runMethod · 0.85
executeMethod · 0.85
runMethod · 0.85

Calls 3

resolve_serverMethod · 0.80
is_emptyMethod · 0.45