(&self)
| 104 | |
| 105 | impl Command for Disable { |
| 106 | fn run(&self) -> CliResult<()> { |
| 107 | // Data-driven uninstall — mirrors `enable --hooks`. |
| 108 | if let Some(ref manifest) = self.hooks { |
| 109 | return self.run_manifest(manifest); |
| 110 | } |
| 111 | |
| 112 | // Uninstall base: the repo root inside a repository, or the home |
| 113 | // directory outside one — mirroring `enable`. Hooks may also live |
| 114 | // in the home config regardless (integration packages target it |
| 115 | // directly), so the loop below always cleans both scopes. |
| 116 | let install_base = match find_repository_root() { |
| 117 | Ok(root) => root, |
| 118 | Err(_) => { |
| 119 | print_warning( |
| 120 | "No Atomic repository found — removing hooks from the home directory.", |
| 121 | ); |
| 122 | dirs::home_dir().ok_or_else(|| { |
| 123 | crate::error::CliError::Io(std::io::Error::new( |
| 124 | std::io::ErrorKind::NotFound, |
| 125 | "Could not determine the home directory", |
| 126 | )) |
| 127 | })? |
| 128 | } |
| 129 | }; |
| 130 | let registry = AgentRegistry::with_defaults(); |
| 131 | |
| 132 | // Determine which agents to uninstall |
| 133 | let agents_to_disable: Vec<String> = if self.all { |
| 134 | // Uninstall from all agents that have hooks installed |
| 135 | let installed = agents_with_installs(®istry, &install_base); |
| 136 | if installed.is_empty() { |
| 137 | println!("No agent hooks are currently installed."); |
| 138 | return Ok(()); |
| 139 | } |
| 140 | installed |
| 141 | } else if let Some(ref name) = self.agent { |
| 142 | // Specific agent requested — validate it exists |
| 143 | registry |
| 144 | .require(name) |
| 145 | .map_err(|e| crate::error::CliError::InvalidArgument { |
| 146 | message: format!("Unknown agent '{}': {}", name, e), |
| 147 | })?; |
| 148 | vec![name.clone()] |
| 149 | } else { |
| 150 | // Auto: uninstall from all agents that have hooks installed |
| 151 | let installed = agents_with_installs(®istry, &install_base); |
| 152 | if installed.is_empty() { |
| 153 | println!("No agent hooks are currently installed."); |
| 154 | println!("Use 'atomic agent enable' to install hooks first."); |
| 155 | return Ok(()); |
| 156 | } |
| 157 | installed |
| 158 | }; |
| 159 | |
| 160 | // Uninstall hooks for each selected agent |
| 161 | let mut total_removed = 0; |
| 162 | |
| 163 | for agent_name in &agents_to_disable { |
nothing calls this directly
no test coverage detected