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

Method set_server

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

Switch the active default server profile.

(&self, set: &ServerSet)

Source from the content-addressed store, hash-verified

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