From 52554af4f12d9cb8b46793dbccbcf2451a5995da Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Wed, 24 Jul 2024 13:18:54 +0100 Subject: [PATCH] cli: add `rad unblock` command Add the `rad unblock` command for reversing the effect of blocking an NID or RID. In both cases, the entry is removed from the DB, if the policy was set to block -- otherwise it is a no-op. --- radicle-cli/examples/rad-block.md | 12 ++++ radicle-cli/src/commands.rs | 2 + radicle-cli/src/commands/help.rs | 1 + radicle-cli/src/commands/unblock.rs | 98 +++++++++++++++++++++++++++++ radicle-cli/src/main.rs | 7 +++ radicle/src/node/policy.rs | 6 +- radicle/src/node/policy/store.rs | 24 +++++++ 7 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 radicle-cli/src/commands/unblock.rs diff --git a/radicle-cli/examples/rad-block.md b/radicle-cli/examples/rad-block.md index 267229c7..41335027 100644 --- a/radicle-cli/examples/rad-block.md +++ b/radicle-cli/examples/rad-block.md @@ -41,3 +41,15 @@ $ rad seed │ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji block all │ ╰───────────────────────────────────────────────────────────╯ ``` + +If we want to reverse the blocking of the RID we can use `rad unblock`: + +``` +$ rad unblock rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji +✓ The 'block' policy for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji is removed +``` + +``` +$ rad seed +No seeding policies to show. +``` diff --git a/radicle-cli/src/commands.rs b/radicle-cli/src/commands.rs index 6808f7ff..e4df12c1 100644 --- a/radicle-cli/src/commands.rs +++ b/radicle-cli/src/commands.rs @@ -52,6 +52,8 @@ pub mod rad_self; pub mod rad_stats; #[path = "commands/sync.rs"] pub mod rad_sync; +#[path = "commands/unblock.rs"] +pub mod rad_unblock; #[path = "commands/unfollow.rs"] pub mod rad_unfollow; #[path = "commands/unseed.rs"] diff --git a/radicle-cli/src/commands/help.rs b/radicle-cli/src/commands/help.rs index 6027dd85..79ba11bf 100644 --- a/radicle-cli/src/commands/help.rs +++ b/radicle-cli/src/commands/help.rs @@ -33,6 +33,7 @@ const COMMANDS: &[Help] = &[ rad_self::HELP, rad_seed::HELP, rad_follow::HELP, + rad_unblock::HELP, rad_unfollow::HELP, rad_unseed::HELP, rad_remote::HELP, diff --git a/radicle-cli/src/commands/unblock.rs b/radicle-cli/src/commands/unblock.rs new file mode 100644 index 00000000..6a144c3f --- /dev/null +++ b/radicle-cli/src/commands/unblock.rs @@ -0,0 +1,98 @@ +use std::ffi::OsString; + +use radicle::prelude::{NodeId, RepoId}; + +use crate::terminal as term; +use crate::terminal::args; +use crate::terminal::args::{Args, Error, Help}; + +pub const HELP: Help = Help { + name: "unblock", + description: "Unblock repositories or nodes to allow them to be seeded or followed", + version: env!("RADICLE_VERSION"), + usage: r#" +Usage + + rad unblock [