Confirm the slug resolves to an org on the server. Returns a [`CliError::InvalidArgument`] with a clean, slug-specific message on 404 so the user sees the actual problem (typo) rather than a raw HTTP response. Other failures (network, auth) bubble up so the user can distinguish "wrong slug" from "server unreachable".
(slug: &str)
| 134 | /// a raw HTTP response. Other failures (network, auth) bubble up so the |
| 135 | /// user can distinguish "wrong slug" from "server unreachable". |
| 136 | fn verify_org_exists(slug: &str) -> CliResult<()> { |
| 137 | let rt = tokio::runtime::Runtime::new() |
| 138 | .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to create async runtime: {e}")))?; |
| 139 | |
| 140 | rt.block_on(async { |
| 141 | let (client, _resolved) = build_client_with_org(Some(slug), None).await?; |
| 142 | match atomic_teams::org::get_org(&client, slug).await { |
| 143 | Ok(_) => Ok(()), |
| 144 | Err(e) if is_org_not_found(&e) => Err(CliError::InvalidArgument { |
| 145 | message: format!( |
| 146 | "Organization '{slug}' not found on the server.\n \ |
| 147 | Check the slug with: atomic org list\n \ |
| 148 | Or pass --no-verify to set the value without checking." |
| 149 | ), |
| 150 | }), |
| 151 | Err(e) => Err(CliError::RemoteError { |
| 152 | message: e.to_string(), |
| 153 | url: None, |
| 154 | }), |
| 155 | } |
| 156 | }) |
| 157 | } |
| 158 | |
| 159 | fn is_org_not_found(err: &atomic_teams::TeamsError) -> bool { |
| 160 | matches!(err, atomic_teams::TeamsError::OrgNotFound(_)) |
nothing calls this directly
no test coverage detected