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

Function resolve_workspace

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

Resolve the workspace slug for a command, with fallback to the org-scoped default workspace from global config. Uses the legacy (single-server) config path. Prefer [`resolve_workspace_with_server`] when you have already resolved the active server. Resolution order: 1. `--workspace` override (if `Some(non-empty)`) 2. `server.default_workspaces[org_slug]` from global config 3. Error with a hint to

(org_slug: &str, workspace_override: Option<&str>)

Source from the content-addressed store, hash-verified

326/// `None` (not provided → fall back to default) from `Some("")` (provided
327/// empty → error) prevents a class of confusing bugs.
328pub fn resolve_workspace(org_slug: &str, workspace_override: Option<&str>) -> CliResult<String> {
329 if let Some(s) = workspace_override {
330 if s.is_empty() {
331 return Err(CliError::InvalidArgument {
332 message: "Workspace slug cannot be empty.".to_string(),
333 });
334 }
335 return Ok(s.to_string());
336 }
337
338 let config = GlobalConfig::load()
339 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load global config: {}", e)))?;
340
341 config
342 .server
343 .default_workspaces
344 .get(org_slug)
345 .cloned()
346 .ok_or_else(|| CliError::InvalidArgument {
347 message: format!(
348 "No workspace specified for org '{org_slug}'.\n \
349 Use --workspace or set a default with: atomic workspace set <slug>"
350 ),
351 })
352}
353
354/// Resolve a flexible identity reference to a UUID.
355///

Callers 5

runMethod · 0.85
executeMethod · 0.85
runMethod · 0.85

Calls 2

getMethod · 0.65
is_emptyMethod · 0.45