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

Method set_server

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

Switch the active default server profile.

(&self, set: &ServerSet)

Source from the content-addressed store, hash-verified

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