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

Function resolve_org_with_server

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

151/// An explicit empty string (`--org ""`) is an error: the user asked for "no
152/// org" which never makes sense.
153pub fn resolve_org_with_server(
154 org_override: Option<&str>,
155 server: &atomic_config::ServerConfig,
156) -> CliResult<String> {
157 if let Some(s) = org_override {
158 if s.is_empty() {
159 return Err(CliError::InvalidArgument {
160 message: "Organization slug cannot be empty.".to_string(),
161 });
162 }
163 return Ok(s.to_string());
164 }
165
166 server
167 .default_org
168 .clone()
169 .ok_or_else(|| CliError::InvalidArgument {
170 message: "No organization specified.\n \
171 Use --org or set a default with: atomic org set <slug>"
172 .to_string(),
173 })
174}
175
176/// Resolve the org slug using the legacy (single-server) config path.
177///

Callers 1

build_client_with_orgFunction · 0.85

Calls 2

is_emptyMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected