| 60 | |
| 61 | impl Command for Delete { |
| 62 | fn run(&self) -> CliResult<()> { |
| 63 | // Get the tag name |
| 64 | let name = self |
| 65 | .name |
| 66 | .as_ref() |
| 67 | .ok_or_else(|| CliError::InvalidArgument { |
| 68 | message: "Tag name is required".to_string(), |
| 69 | })?; |
| 70 | |
| 71 | // Find the repository |
| 72 | let repo_root = find_repository_root()?; |
| 73 | let repo = Repository::open(&repo_root).map_err(|e| match e { |
| 74 | atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound { |
| 75 | searched_path: path.into(), |
| 76 | }, |
| 77 | other => CliError::Repository(other), |
| 78 | })?; |
| 79 | |
| 80 | // Delete the tag |
| 81 | let deleted = repo.delete_tag(name).map_err(CliError::Repository)?; |
| 82 | |
| 83 | if deleted { |
| 84 | print_success(&format!("Deleted tag: {}", emphasis(name))); |
| 85 | } else { |
| 86 | println!("{}", hint(&format!("Tag '{}' does not exist", name))); |
| 87 | } |
| 88 | |
| 89 | Ok(()) |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // Tests |