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

Function resolve_workspace_with_server

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

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