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

Function activate_server_for_identity

atomic-cli/src/commands/identity/mod.rs:360–390  ·  view source on GitHub ↗

When an identity becomes the active default, automatically activate the server profile bound to it (if any). Looks for a named profile in `~/.atomic/config.toml` whose `identity` field matches `identity_name`. If found, sets `default_server` to that profile name and saves the config. Emits a hint so the user knows the server switched alongside the identity. This is intentionally non-fatal: if th

(identity_name: &str)

Source from the content-addressed store, hash-verified

358/// a debug log is emitted and the command still succeeds — the identity
359/// switch itself is the important operation.
360pub fn activate_server_for_identity(identity_name: &str) {
361 let mut config = match GlobalConfig::load() {
362 Ok(c) => c,
363 Err(e) => {
364 log::debug!("Could not load config for server auto-activation: {}", e);
365 return;
366 }
367 };
368
369 // Find a named server profile whose identity binding matches.
370 let matching_profile = config
371 .servers
372 .iter()
373 .find(|(_, srv)| srv.identity.as_deref() == Some(identity_name))
374 .map(|(name, _)| name.clone());
375
376 if let Some(profile_name) = matching_profile {
377 // Only update + print if it's actually changing.
378 if config.default_server.as_deref() != Some(&profile_name) {
379 config.default_server = Some(profile_name.clone());
380 if let Err(e) = config.save() {
381 log::debug!("Could not save config for server auto-activation: {}", e);
382 return;
383 }
384 crate::output::print_hint(&format!(
385 "Server profile '{}' activated (bound to identity '{}')",
386 profile_name, identity_name
387 ));
388 }
389 }
390}
391
392/// Format an identity type for display.
393pub fn format_identity_type(identity_type: &atomic_identity::IdentityType) -> &'static str {

Callers 2

runMethod · 0.85
runMethod · 0.85

Calls 4

print_hintFunction · 0.85
iterMethod · 0.45
cloneMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected