Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli/issue: handle --[no-]announce
Fintan Halpenny committed 7 months ago
commit bc2ffc082e603fd4077cf76b2777b98384ed3c23
parent c2792a546d458d990946b3e63f0d05e5e77712b0
2 files changed +19 -2
modified crates/radicle-cli/src/commands/issue.rs
@@ -40,8 +40,9 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
    };
    let repo = profile.storage.repository_mut(rid)?;

+
    let should_announce = args.should_announce();
    let command = args.command.unwrap_or_default();
-
    let announce = !args.no_announce
+
    let announce = should_announce
        && matches!(
            &command,
            Command::Open { .. }
modified crates/radicle-cli/src/commands/issue/args.rs
@@ -37,11 +37,16 @@ pub struct Args {
    #[clap(global = true)]
    pub(crate) quiet: bool,

+
    // This is a workaround for the lack of `--[no-]` handling
    /// Do not announce issue changes to the network
-
    #[arg(long)]
+
    #[arg(long, overrides_with("announce"))]
    #[arg(value_name = "no-announce")]
    #[clap(global = true)]
    pub(crate) no_announce: bool,
+
    #[arg(long)]
+
    #[arg(value_name = "announce", overrides_with("no_announce"), hide(true))]
+
    #[clap(global = true)]
+
    pub(crate) announce: bool,

    /// Show only the issue header, hiding the comments
    #[arg(long)]
@@ -60,6 +65,17 @@ pub struct Args {
    pub(crate) verbose: bool,
}

+
impl Args {
+
    pub fn should_announce(&self) -> bool {
+
        match (self.announce, self.no_announce) {
+
            (true, false) => true,
+
            (false, true) => false,
+
            // Default it to announce
+
            (_, _) => true,
+
        }
+
    }
+
}
+

/// Commands to create, view, and edit Radicle issues
#[derive(Subcommand, Debug)]
pub(crate) enum Command {