(&self)
| 99 | |
| 100 | impl 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(®istry, &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(®istry, &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; |
nothing calls this directly
no test coverage detected