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

Function resolve_org_with_server

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

Resolve the org slug for a command, with fallback to the configured default. This variant uses the *active* server's `default_org` so that per-server org defaults are respected. Resolution order: 1. `--org` override (if `Some(non-empty)`) 2. `server.default_org` from the resolved server profile 3. Error with a hint to run `atomic org set` An explicit empty string (`--org ""`) is an error: the u

(
    org_override: Option<&str>,
    server: &atomic_config::ServerConfig,
)

Source from the content-addressed store, hash-verified

224/// An explicit empty string (`--org ""`) is an error: the user asked for "no
225/// org" which never makes sense.
226pub fn resolve_org_with_server(
227 org_override: Option<&str>,
228 server: &atomic_config::ServerConfig,
229) -> CliResult<String> {
230 if let Some(s) = org_override {
231 if s.is_empty() {
232 return Err(CliError::InvalidArgument {
233 message: "Organization slug cannot be empty.".to_string(),
234 });
235 }
236 return Ok(s.to_string());
237 }
238
239 server
240 .default_org
241 .clone()
242 .ok_or_else(|| CliError::InvalidArgument {
243 message: "No organization specified.\n \
244 Use --org or set a default with: atomic org set <slug>"
245 .to_string(),
246 })
247}
248
249/// Resolve the org slug using the legacy (single-server) config path.
250///

Callers 1

build_client_with_orgFunction · 0.85

Calls 2

is_emptyMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected