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

Function resolve_workspace_with_server

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

309/// 2. `server.default_workspaces[org_slug]` from the resolved server profile
310/// 3. Error with a hint to run `atomic workspace set`
311pub fn resolve_workspace_with_server(
312 org_slug: &str,
313 workspace_override: Option<&str>,
314 server: &atomic_config::ServerConfig,
315) -> CliResult<String> {
316 if let Some(s) = workspace_override {
317 if s.is_empty() {
318 return Err(CliError::InvalidArgument {
319 message: "Workspace slug cannot be empty.".to_string(),
320 });
321 }
322 return Ok(s.to_string());
323 }
324
325 server
326 .default_workspaces
327 .get(org_slug)
328 .cloned()
329 .ok_or_else(|| CliError::InvalidArgument {
330 message: format!(
331 "No workspace specified for org '{org_slug}'.\n \
332 Use --workspace or set a default with: atomic workspace set <slug>"
333 ),
334 })
335}
336
337/// Resolve the workspace slug for a command, with fallback to the
338/// 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