| 118 | |
| 119 | impl 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 | |
| 167 | impl Delete { |