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

Method set_identity_for_server

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

Bind (or clear) an identity for a server profile.

(&self, cmd: &ServerSetIdentity)

Source from the content-addressed store, hash-verified

445
446 /// Bind (or clear) an identity for a server profile.
447 fn set_identity_for_server(&self, cmd: &ServerSetIdentity) -> CliResult<()> {
448 let mut config = GlobalConfig::load()
449 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load config: {}", e)))?;
450
451 let profile =
452 config
453 .servers
454 .get_mut(&cmd.name)
455 .ok_or_else(|| CliError::InvalidArgument {
456 message: format!(
457 "Server profile '{}' not found. \
458 Use 'atomic server add {} <url>' to create it.",
459 cmd.name, cmd.name
460 ),
461 })?;
462
463 if cmd.clear {
464 profile.identity = None;
465 config
466 .save()
467 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to save config: {}", e)))?;
468 print_success(&format!(
469 "Identity cleared for server profile '{}'",
470 cmd.name
471 ));
472 print_hint("Management commands will now use the global default identity.");
473 } else {
474 let identity_name = cmd.identity.as_deref().unwrap();
475 profile.identity = Some(identity_name.to_string());
476 config
477 .save()
478 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to save config: {}", e)))?;
479 print_success(&format!(
480 "Identity '{}' bound to server profile '{}'",
481 identity_name, cmd.name
482 ));
483 }
484
485 Ok(())
486 }
487}
488
489impl Command for ServerCmd {

Callers 1

runMethod · 0.80

Calls 5

print_successFunction · 0.85
print_hintFunction · 0.85
get_mutMethod · 0.80
saveMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected