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:450–489  ·  view source on GitHub ↗

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

(&self, cmd: &ServerSetIdentity)

Source from the content-addressed store, hash-verified

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