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

Method run

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

Source from the content-addressed store, hash-verified

80
81impl Command for Disable {
82 fn run(&self) -> CliResult<()> {
83 // Data-driven uninstall — mirrors `enable --hooks`.
84 if let Some(ref manifest) = self.hooks {
85 return self.run_manifest(manifest);
86 }
87
88 // Global uninstall — removes from ~/.claude/settings.json
89 if self.global {
90 return self.run_global();
91 }
92
93 let repo_root = find_repository_root()?;
94
95 let registry = AgentRegistry::with_defaults();
96
97 // Determine which agents to uninstall
98 let agents_to_disable: Vec<&str> = if self.all {
99 // Uninstall from all agents that have hooks installed
100 let installed = registry.installed(&repo_root);
101 if installed.is_empty() {
102 println!("No agent hooks are currently installed.");
103 return Ok(());
104 }
105 installed
106 } else if let Some(ref name) = self.agent {
107 // Specific agent requested — validate it exists
108 registry
109 .require(name)
110 .map_err(|e| crate::error::CliError::InvalidArgument {
111 message: format!("Unknown agent '{}': {}", name, e),
112 })?;
113 vec![name.as_str()]
114 } else {
115 // Auto: uninstall from all agents that have hooks installed
116 let installed = registry.installed(&repo_root);
117 if installed.is_empty() {
118 println!("No agent hooks are currently installed.");
119 println!("Use 'atomic agent enable' to install hooks first.");
120 return Ok(());
121 }
122 installed
123 };
124
125 // Uninstall hooks for each selected agent
126 let mut total_removed = 0;
127
128 for agent_name in &agents_to_disable {
129 let agent = match registry.get(agent_name) {
130 Some(a) => a,
131 None => {
132 print_warning(&format!(
133 "Agent '{}' not found in registry — skipping.",
134 agent_name,
135 ));
136 continue;
137 }
138 };
139

Callers

nothing calls this directly

Calls 12

find_repository_rootFunction · 0.85
print_warningFunction · 0.85
print_successFunction · 0.85
print_errorFunction · 0.85
installedMethod · 0.80
getMethod · 0.65
run_manifestMethod · 0.45
run_globalMethod · 0.45
is_emptyMethod · 0.45
requireMethod · 0.45
is_installedMethod · 0.45
uninstallMethod · 0.45

Tested by

no test coverage detected