diff options
author | Cyborus <cyborus@cyborus.xyz> | 2024-05-14 22:45:58 +0200 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2024-05-14 22:45:58 +0200 |
commit | 6687c9e2c11b1305d6a838155a42acde3c818730 (patch) | |
tree | 5cd457b839b629bb2abf79c85e4f0f16cb7381cf /src | |
parent | Merge pull request 'don't check ignored files when checking for uncommitted c... (diff) | |
download | forgejo-cli-6687c9e2c11b1305d6a838155a42acde3c818730.tar.xz forgejo-cli-6687c9e2c11b1305d6a838155a42acde3c818730.zip |
add `repo star` and `repo unstar`
Diffstat (limited to 'src')
-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 ed61c28..2cc78d7 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -275,6 +275,12 @@ pub enum RepoCommand { #[clap(long, short = 'R')] remote: Option<String>, }, + Star { + repo: String, + }, + Unstar { + repo: String, + }, Browse { name: Option<String>, #[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(); |