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

Function resolve_workspace_with_server

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

Resolve the workspace slug for a command, with fallback to the org-scoped default workspace from a server config. Workspaces are org-scoped, so the lookup is keyed by `org_slug`. The caller is responsible for resolving the org first (typically with [`resolve_org_with_server`]). Resolution order: 1. `--workspace` override (if `Some(non-empty)`) 2. `server.default_workspaces[org_slug]` from the re

(
    org_slug: &str,
    workspace_override: Option<&str>,
    server: &atomic_config::ServerConfig,
)

Source from the content-addressed store, hash-verified

381/// 2. `server.default_workspaces[org_slug]` from the resolved server profile
382/// 3. Error with a hint to run `atomic workspace set`
383pub fn resolve_workspace_with_server(
384 org_slug: &str,
385 workspace_override: Option<&str>,
386 server: &atomic_config::ServerConfig,
387) -> CliResult<String> {
388 if let Some(s) = workspace_override {
389 if s.is_empty() {
390 return Err(CliError::InvalidArgument {
391 message: "Workspace slug cannot be empty.".to_string(),
392 });
393 }
394 return Ok(s.to_string());
395 }
396
397 server
398 .default_workspaces
399 .get(org_slug)
400 .cloned()
401 .ok_or_else(|| CliError::InvalidArgument {
402 message: format!(
403 "No workspace specified for org '{org_slug}'.\n \
404 Use --workspace or set a default with: atomic workspace set <slug>"
405 ),
406 })
407}
408
409/// Resolve the workspace slug for a command, with fallback to the
410/// org-scoped default workspace from the **active** server profile.

Callers 1

resolve_workspaceFunction · 0.85

Calls 2

getMethod · 0.65
is_emptyMethod · 0.45

Tested by

no test coverage detected