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

Method run

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

Source from the content-addressed store, hash-verified

104
105impl 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(&registry, &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(&registry, &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 {

Callers

nothing calls this directly

Calls 14

find_repository_rootFunction · 0.85
print_warningFunction · 0.85
agents_with_installsFunction · 0.85
uninstallFunction · 0.85
print_successFunction · 0.85
print_errorFunction · 0.85
getMethod · 0.65
run_manifestMethod · 0.45
is_emptyMethod · 0.45
requireMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected