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

Method list_servers

atomic-cli/src/commands/server/mod.rs:175–225  ·  view source on GitHub ↗

List all configured server profiles.

(&self)

Source from the content-addressed store, hash-verified

173impl ServerCmd {
174 /// List all configured server profiles.
175 fn list_servers(&self) -> CliResult<()> {
176 let config = GlobalConfig::load()
177 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load config: {}", e)))?;
178
179 if config.servers.is_empty() {
180 print_hint(
181 "No named server profiles configured.\n \
182 Use 'atomic server add <name> <url>' to add one.\n \
183 The legacy [server] block is always available as the default.",
184 );
185 if config.server.is_configured() {
186 println!();
187 println!(
188 " Active server (legacy): {}",
189 config.server.url.as_deref().unwrap_or("(none)")
190 );
191 if let Some(ref org) = config.server.default_org {
192 println!(" Default org: {}", org);
193 }
194 }
195 return Ok(());
196 }
197
198 let active = config.default_server.as_deref();
199
200 for (name, profile) in &config.servers {
201 let is_active = Some(name.as_str()) == active;
202 let active_marker = if is_active { " *" } else { "" };
203 let url = profile.url.as_deref().unwrap_or("(no url)");
204 let org = profile
205 .default_org
206 .as_deref()
207 .map(|o| format!(", org: {}", o))
208 .unwrap_or_default();
209 let identity = profile
210 .identity
211 .as_deref()
212 .map(|i| format!(", identity: {}", i))
213 .unwrap_or_default();
214
215 println!("{}{}\t{}{}{}", name, active_marker, url, org, identity);
216 }
217
218 if active.is_none() {
219 println!();
220 print_hint("No named profile is active — using the legacy [server] block.");
221 print_hint("Run 'atomic server set <name>' to activate a profile.");
222 }
223
224 Ok(())
225 }
226
227 /// Add a new server profile.
228 fn add_server(&self, add: &ServerAdd) -> CliResult<()> {

Callers 1

runMethod · 0.80

Calls 5

print_hintFunction · 0.85
is_configuredMethod · 0.80
is_noneMethod · 0.80
is_emptyMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected