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

Function resolve_workspace_with_server

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

211/// 2. `server.default_workspaces[org_slug]` from the resolved server profile
212/// 3. Error with a hint to run `atomic workspace set`
213pub fn resolve_workspace_with_server(
214 org_slug: &str,
215 workspace_override: Option<&str>,
216 server: &atomic_config::ServerConfig,
217) -> CliResult<String> {
218 if let Some(s) = workspace_override {
219 if s.is_empty() {
220 return Err(CliError::InvalidArgument {
221 message: "Workspace slug cannot be empty.".to_string(),
222 });
223 }
224 return Ok(s.to_string());
225 }
226
227 server
228 .default_workspaces
229 .get(org_slug)
230 .cloned()
231 .ok_or_else(|| CliError::InvalidArgument {
232 message: format!(
233 "No workspace specified for org '{org_slug}'.\n \
234 Use --workspace or set a default with: atomic workspace set <slug>"
235 ),
236 })
237}
238
239/// Resolve the workspace slug for a command, with fallback to the
240/// 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