diff options
author | Cyborus <cyborus@cyborus.xyz> | 2024-06-18 19:06:53 +0200 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2024-07-08 20:54:57 +0200 |
commit | ccf1688d15d68f66a5388f66bdb891f93214bb9b (patch) | |
tree | 79cd75b0842c6688e7ce5d8f74596d03ab131e98 | |
parent | feat(user): following commands (diff) | |
download | forgejo-cli-ccf1688d15d68f66a5388f66bdb891f93214bb9b.tar.xz forgejo-cli-ccf1688d15d68f66a5388f66bdb891f93214bb9b.zip |
feat(user): blocking and unblocking
-rw-r--r-- | src/user.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/user.rs b/src/user.rs index 31a9ef6..3010f69 100644 --- a/src/user.rs +++ b/src/user.rs @@ -38,6 +38,14 @@ pub enum UserSubcommand { /// The name of the user whose followers to list user: Option<String>, }, + Block { + /// The name of the user to block + user: String, + }, + Unblock { + /// The name of the user to unblock + user: String, + }, } impl UserCommand { @@ -53,6 +61,8 @@ impl UserCommand { UserSubcommand::Unfollow { user } => unfollow_user(&api, &user).await?, UserSubcommand::Following { user } => list_following(&api, user.as_deref()).await?, UserSubcommand::Followers { user } => list_followers(&api, user.as_deref()).await?, + UserSubcommand::Block { user } => block_user(&api, &user).await?, + UserSubcommand::Unblock { user } => unblock_user(&api, &user).await?, } Ok(()) } @@ -238,3 +248,15 @@ async fn list_followers(api: &Forgejo, user: Option<&str>) -> eyre::Result<()> { Ok(()) } + +async fn block_user(api: &Forgejo, user: &str) -> eyre::Result<()> { + api.user_block_user(user).await?; + println!("Blocked {user}"); + Ok(()) +} + +async fn unblock_user(api: &Forgejo, user: &str) -> eyre::Result<()> { + api.user_unblock_user(user).await?; + println!("Unblocked {user}"); + Ok(()) +} |