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

Method run

atomic-cli/src/commands/view/delete.rs:120–164  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

118
119impl Command for Delete {
120 fn run(&self) -> CliResult<()> {
121 // Get the view name
122 let name = self
123 .name
124 .as_ref()
125 .ok_or_else(|| CliError::InvalidArgument {
126 message: "View name is required".to_string(),
127 })?;
128
129 // The service executes a dispatched delete directly, so orphan
130 // warnings and the acknowledgement are surfaced client-side BEFORE
131 // any dispatch. The analysis is best-effort: a refusal to proceed
132 // (cancel / no terminal) is final, but any other analysis failure
133 // is deferred so the dispatch or local execution below surfaces
134 // the canonical error.
135 let pre_confirmed = !self.force;
136 if pre_confirmed {
137 let gate = match find_repository_root() {
138 Ok(repo_root) => match Repository::open(&repo_root) {
139 Ok(repo) => self.validate_and_warn(&repo, name, true, confirm_in_terminal),
140 Err(_) => Ok(()),
141 },
142 Err(e) => Err(e),
143 };
144 if let Err(e @ (CliError::Cancelled | CliError::InvalidArgument { .. })) = gate {
145 return Err(e);
146 }
147 }
148
149 // Route through the daemon when reachable.
150 if crate::commands::rpc::view_delete(self)? {
151 return Ok(());
152 }
153
154 // Find the repository
155 let repo_root = find_repository_root()?;
156 let mut repo = Repository::open(&repo_root).map_err(|e| match e {
157 atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound {
158 searched_path: path.into(),
159 },
160 other => CliError::Repository(other),
161 })?;
162
163 self.execute_with_repo_gated(&mut repo, name, pre_confirmed, confirm_in_terminal)
164 }
165}
166
167impl Delete {

Callers 5

test_run_without_nameFunction · 0.45
test_delete_current_viewFunction · 0.45

Calls 7

find_repository_rootFunction · 0.85
openFunction · 0.85
view_deleteFunction · 0.85
RepositoryClass · 0.85
as_refMethod · 0.80
validate_and_warnMethod · 0.80

Tested by 5

test_run_without_nameFunction · 0.36
test_delete_current_viewFunction · 0.36