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

Function resolve_workspace_with_server

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

284/// 2. `server.default_workspaces[org_slug]` from the resolved server profile
285/// 3. Error with a hint to run `atomic workspace set`
286pub fn resolve_workspace_with_server(
287 org_slug: &str,
288 workspace_override: Option<&str>,
289 server: &atomic_config::ServerConfig,
290) -> CliResult<String> {
291 if let Some(s) = workspace_override {
292 if s.is_empty() {
293 return Err(CliError::InvalidArgument {
294 message: "Workspace slug cannot be empty.".to_string(),
295 });
296 }
297 return Ok(s.to_string());
298 }
299
300 server
301 .default_workspaces
302 .get(org_slug)
303 .cloned()
304 .ok_or_else(|| CliError::InvalidArgument {
305 message: format!(
306 "No workspace specified for org '{org_slug}'.\n \
307 Use --workspace or set a default with: atomic workspace set <slug>"
308 ),
309 })
310}
311
312/// Resolve the workspace slug for a command, with fallback to the
313/// org-scoped default workspace from global config.

Callers

nothing calls this directly

Calls 2

getMethod · 0.65
is_emptyMethod · 0.45

Tested by

no test coverage detected