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

Method run

atomic-cli/src/commands/identity/delete.rs:62–124  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

60
61impl Command for Delete {
62 fn run(&self) -> CliResult<()> {
63 // Open the identity store
64 let mut store = IdentityStore::open_default().map_err(|e| {
65 CliError::Internal(anyhow::anyhow!("Failed to open identity store: {}", e))
66 })?;
67
68 // Load the identity by name to get its ID
69 let identity = store
70 .load_by_name(&self.name)
71 .map_err(|_| CliError::IdentityNotFound(self.name.clone()))?;
72
73 // Check if this is the default identity
74 let is_default = store
75 .get_default()
76 .ok()
77 .flatten()
78 .map(|d| d.id == identity.id)
79 .unwrap_or(false);
80
81 if is_default && !self.force {
82 print_warning(&format!(
83 "Warning: '{}' is your default identity",
84 self.name
85 ));
86 }
87
88 // Confirm deletion unless --force is used
89 if !self.force {
90 use std::io::{self, Write};
91
92 print!(
93 "Are you sure you want to delete identity '{}'? [y/N] ",
94 self.name
95 );
96 io::stdout().flush().unwrap();
97
98 let mut input = String::new();
99 io::stdin()
100 .read_line(&mut input)
101 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to read input: {}", e)))?;
102
103 let input = input.trim().to_lowercase();
104 if input != "y" && input != "yes" {
105 println!("Cancelled");
106 return Ok(());
107 }
108 }
109
110 // Delete the identity
111 store
112 .delete(&identity.id)
113 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to delete identity: {}", e)))?;
114
115 print_success(&format!("Deleted identity: {}", self.name));
116
117 if is_default {
118 println!();
119 print_warning("Your default identity has been deleted. Set a new default with:");

Callers

nothing calls this directly

Calls 8

print_warningFunction · 0.85
print_successFunction · 0.85
load_by_nameMethod · 0.80
cloneMethod · 0.45
get_defaultMethod · 0.45
unwrapMethod · 0.45
flushMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected