(&self)
| 80 | |
| 81 | impl 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 |
nothing calls this directly
no test coverage detected