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

Method run

atomic-cli/src/commands/agent/disable.rs:101–225  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

99
100impl Command for Disable {
101 fn run(&self) -> CliResult<()> {
102 // Data-driven uninstall — mirrors `enable --hooks`.
103 if let Some(ref manifest) = self.hooks {
104 return self.run_manifest(manifest);
105 }
106
107 // Global uninstall — removes from ~/.claude/settings.json
108 if self.global {
109 return self.run_global();
110 }
111
112 let repo_root = find_repository_root()?;
113 let registry = AgentRegistry::with_defaults();
114
115 // Determine which agents to uninstall
116 let agents_to_disable: Vec<String> = if self.all {
117 // Uninstall from all agents that have hooks installed
118 let installed = agents_with_installs(&registry, &repo_root);
119 if installed.is_empty() {
120 println!("No agent hooks are currently installed.");
121 return Ok(());
122 }
123 installed
124 } else if let Some(ref name) = self.agent {
125 // Specific agent requested — validate it exists
126 registry
127 .require(name)
128 .map_err(|e| crate::error::CliError::InvalidArgument {
129 message: format!("Unknown agent '{}': {}", name, e),
130 })?;
131 vec![name.clone()]
132 } else {
133 // Auto: uninstall from all agents that have hooks installed
134 let installed = agents_with_installs(&registry, &repo_root);
135 if installed.is_empty() {
136 println!("No agent hooks are currently installed.");
137 println!("Use 'atomic agent enable' to install hooks first.");
138 return Ok(());
139 }
140 installed
141 };
142
143 // Uninstall hooks for each selected agent
144 let mut total_removed = 0;
145
146 for agent_name in &agents_to_disable {
147 let agent = match registry.get(agent_name) {
148 Some(a) => a,
149 None => {
150 print_warning(&format!(
151 "Agent '{}' not found in registry — skipping.",
152 agent_name,
153 ));
154 continue;
155 }
156 };
157
158 let mut removed_any = false;

Callers

nothing calls this directly

Calls 13

find_repository_rootFunction · 0.85
agents_with_installsFunction · 0.85
print_warningFunction · 0.85
uninstallFunction · 0.85
print_successFunction · 0.85
print_errorFunction · 0.85
getMethod · 0.65
run_manifestMethod · 0.45
run_globalMethod · 0.45
is_emptyMethod · 0.45
requireMethod · 0.45
is_installedMethod · 0.45

Tested by

no test coverage detected