From 6687c9e2c11b1305d6a838155a42acde3c818730 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 14 May 2024 16:45:58 -0400 Subject: [PATCH] add `repo star` and `repo unstar` --- src/repo.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/repo.rs b/src/repo.rs index ed61c28..2cc78d7 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -275,6 +275,12 @@ pub enum RepoCommand { #[clap(long, short = 'R')] remote: Option, }, + Star { + repo: String, + }, + Unstar { + repo: String, + }, Browse { name: Option, #[clap(long, short = 'R')] @@ -456,6 +462,21 @@ impl RepoCommand { println!("View online at {html_url}"); } } + RepoCommand::Star { repo } => { + let repo = RepoInfo::get_current(host_name, Some(&repo), None)?; + let api = keys.get_api(&repo.host_url())?; + let name = repo.name().unwrap(); + api.user_current_put_star(name.owner(), name.name()).await?; + println!("Starred {}/{}!", name.owner(), name.name()); + } + RepoCommand::Unstar { repo } => { + let repo = RepoInfo::get_current(host_name, Some(&repo), None)?; + let api = keys.get_api(&repo.host_url())?; + let name = repo.name().unwrap(); + api.user_current_delete_star(name.owner(), name.name()) + .await?; + println!("Removed star from {}/{}", name.owner(), name.name()); + } RepoCommand::Browse { name, remote } => { let repo = RepoInfo::get_current(host_name, name.as_deref(), remote.as_deref())?; let mut url = repo.host_url().clone();