| 61 | |
| 62 | impl Command for Delete { |
| 63 | fn run(&self) -> CliResult<()> { |
| 64 | // Route every form through the service layer (the handler runs the |
| 65 | // same domain delete and the wire carries the existed flag). |
| 66 | if crate::commands::rpc::tag_delete(self)? { |
| 67 | return Ok(()); |
| 68 | } |
| 69 | |
| 70 | // Get the tag name |
| 71 | let name = self |
| 72 | .name |
| 73 | .as_ref() |
| 74 | .ok_or_else(|| CliError::InvalidArgument { |
| 75 | message: "Tag name is required".to_string(), |
| 76 | })?; |
| 77 | |
| 78 | // Find the repository |
| 79 | let repo_root = find_repository_root()?; |
| 80 | let mut repo = |
| 81 | Repository::open_for_workspace_transaction(&repo_root).map_err(|e| match e { |
| 82 | atomic_repository::RepositoryError::NotFound { path } => { |
| 83 | CliError::RepositoryNotFound { |
| 84 | searched_path: path.into(), |
| 85 | } |
| 86 | } |
| 87 | other => CliError::Repository(other), |
| 88 | })?; |
| 89 | |
| 90 | let workspace = enter_workspace(&mut repo, WorkspaceTxnMode::Reconcile)?; |
| 91 | |
| 92 | // Delete the tag |
| 93 | let deleted = repo |
| 94 | .delete_tag_from_view(name, &workspace.view().name) |
| 95 | .map_err(CliError::Repository)?; |
| 96 | |
| 97 | if deleted { |
| 98 | print_success(&format!("Deleted tag: {}", emphasis(name))); |
| 99 | } else { |
| 100 | println!("{}", hint(&format!("Tag '{}' does not exist", name))); |
| 101 | } |
| 102 | |
| 103 | Ok(()) |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // Tests |