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

Method set_server

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

Switch the active default server profile.

(&self, set: &ServerSet)

Source from the content-addressed store, hash-verified

292
293 /// Switch the active default server profile.
294 fn set_server(&self, set: &ServerSet) -> CliResult<()> {
295 let mut config = GlobalConfig::load()
296 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load config: {}", e)))?;
297
298 if set.revert {
299 config.default_server = None;
300 config
301 .save()
302 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to save config: {}", e)))?;
303 print_success("Reverted to legacy [server] block");
304 return Ok(());
305 }
306
307 let name = set.name.as_deref().unwrap();
308
309 if !config.servers.contains_key(name) {
310 return Err(CliError::InvalidArgument {
311 message: format!(
312 "Server profile '{}' not found.\n \
313 Use 'atomic server add {} <url>' to create it.",
314 name, name
315 ),
316 });
317 }
318
319 config.default_server = Some(name.to_string());
320 config
321 .save()
322 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to save config: {}", e)))?;
323
324 print_success(&format!("Active server is now '{}'", name));
325
326 let profile = &config.servers[name];
327 if let Some(ref url) = profile.url {
328 println!(" URL: {}", url);
329 }
330 if let Some(ref org) = profile.default_org {
331 println!(" Org: {}", org);
332 }
333 if let Some(ref identity) = profile.identity {
334 println!(" Identity: {}", identity);
335 }
336
337 Ok(())
338 }
339
340 /// Show details for a server profile.
341 fn show_server(&self, show: &ServerShow) -> CliResult<()> {

Callers 1

runMethod · 0.80

Calls 4

print_successFunction · 0.85
contains_keyMethod · 0.80
saveMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected