diff options
author | Cyborus <cyborus@cyborus.xyz> | 2024-07-25 21:33:30 +0200 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2024-07-25 21:33:30 +0200 |
commit | efbefd79ca0c400b69b0716d529719f35d98fee2 (patch) | |
tree | 08a039948dea0c6a94b8a1f90be9eae204a5a522 | |
parent | Merge pull request '`repo create` should not take `RepoArg` for name argument... (diff) | |
download | forgejo-cli-efbefd79ca0c400b69b0716d529719f35d98fee2.tar.xz forgejo-cli-efbefd79ca0c400b69b0716d529719f35d98fee2.zip |
feat: `repo delete`
-rw-r--r-- | src/repo.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/repo.rs b/src/repo.rs index 336e868..f870add 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -326,6 +326,9 @@ pub enum RepoCommand { Unstar { repo: RepoArg, }, + Delete { + repo: RepoArg, + }, Browse { name: Option<RepoArg>, #[clap(long, short = 'R')] @@ -663,6 +666,24 @@ impl RepoCommand { .await?; println!("Removed star from {}/{}", name.owner(), name.name()); } + RepoCommand::Delete { repo } => { + let repo = RepoInfo::get_current(host_name, Some(&repo), None)?; + let api = keys.get_api(&repo.host_url()).await?; + let name = repo.name().unwrap(); + print!( + "Are you sure you want to delete {}/{}? (y/N) ", + name.owner(), + name.name() + ); + let user_response = crate::readline("").await?; + let yes = matches!(user_response.trim(), "y" | "Y" | "yes" | "Yes"); + if yes { + api.repo_delete(name.owner(), name.name()).await?; + println!("Deleted {}/{}", name.owner(), name.name()); + } else { + println!("Did not delete"); + } + } RepoCommand::Browse { name, remote } => { let repo = RepoInfo::get_current(host_name, name.as_ref(), remote.as_deref())?; let mut url = repo.host_url().clone(); |