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

Function resolve_workspace

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

Resolve the workspace slug for a command, with fallback to the org-scoped default workspace from global config. Uses the legacy (single-server) config path. Prefer [`resolve_workspace_with_server`] when you have already resolved the active server. Resolution order: 1. `--workspace` override (if `Some(non-empty)`) 2. `server.default_workspaces[org_slug]` from global config 3. Error with a hint to

(org_slug: &str, workspace_override: Option<&str>)

Source from the content-addressed store, hash-verified

253/// `None` (not provided → fall back to default) from `Some("")` (provided
254/// empty → error) prevents a class of confusing bugs.
255pub fn resolve_workspace(org_slug: &str, workspace_override: Option<&str>) -> CliResult<String> {
256 if let Some(s) = workspace_override {
257 if s.is_empty() {
258 return Err(CliError::InvalidArgument {
259 message: "Workspace slug cannot be empty.".to_string(),
260 });
261 }
262 return Ok(s.to_string());
263 }
264
265 let config = GlobalConfig::load()
266 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load global config: {}", e)))?;
267
268 config
269 .server
270 .default_workspaces
271 .get(org_slug)
272 .cloned()
273 .ok_or_else(|| CliError::InvalidArgument {
274 message: format!(
275 "No workspace specified for org '{org_slug}'.\n \
276 Use --workspace or set a default with: atomic workspace set <slug>"
277 ),
278 })
279}
280
281/// Resolve a flexible identity reference to a UUID.
282///

Callers 5

runMethod · 0.85
executeMethod · 0.85
runMethod · 0.85

Calls 2

getMethod · 0.65
is_emptyMethod · 0.45