Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
Add --author and --authored flags to "rad issue (list)"
Open did:key:z6MkrxqT...yQRh opened 1 month ago

This patch adds filtering functionality for the author of an issue when listing issues.

In large repositories like heartwood, rad issue list lists more than one screen size of issues. For boiling down this list (for example to find issue IDs of issues oneself has authored), this patch introduces the –authored and –author arguments that are already known from rad patch list.

This makes the interface of that subcommand symmetric to rad patch list, which is desireable from a UX standpoint as well.

2 files changed +45 -0 e9245b63 625e775c
modified crates/radicle-cli/src/commands/issue.rs
@@ -2,6 +2,8 @@ mod args;
mod cache;
mod comment;

+
use std::collections::BTreeSet;
+

use anyhow::Context as _;

use radicle::cob::common::Label;
@@ -196,8 +198,14 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
            issue.label(labels, &signer)?;
        }
        Command::List(list_args) => {
+
            let mut authors: BTreeSet<Did> = list_args.authors.iter().cloned().collect();
+
            if list_args.authored {
+
                authors.insert(profile.did());
+
            }
+

            list(
                issues,
+
                authors,
                &list_args.assigned,
                &((&list_args.state).into()),
                &profile,
@@ -241,6 +249,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {

fn list<C>(
    cache: C,
+
    authors: BTreeSet<Did>,
    assigned: &Option<Assigned>,
    state: &Option<State>,
    profile: &profile::Profile,
@@ -272,6 +281,12 @@ where
                }
            };

+
            if !authors.is_empty() {
+
                if !authors.contains(issue.author().id()) {
+
                    return None;
+
                }
+
            }
+

            if let Some(a) = assignee {
                if !issue.assignees().any(|v| v == &Did::from(a)) {
                    return None;
modified crates/radicle-cli/src/commands/issue/args.rs
@@ -212,6 +212,20 @@ pub(crate) struct EmptyArgs {

    #[clap(flatten)]
    pub(crate) state: EmptyStateArgs,
+

+
    /// Show only issues where the given user is an author (may be specified
+
    /// multiple times)
+
    #[arg(
+
        long = "author",
+
        value_name = "DID",
+
        num_args = 1..,
+
        action = clap::ArgAction::Append,
+
    )]
+
    pub(super) authors: Vec<Did>,
+

+
    /// Show only issues that you have authored
+
    #[arg(long)]
+
    pub(super) authored: bool,
}

/// Counterpart to [`ListStateArgs`] for the empty subcommand.
@@ -242,6 +256,20 @@ pub(crate) struct ListArgs {

    #[clap(flatten)]
    pub(crate) state: ListStateArgs,
+

+
    /// Show only issues where the given user is an author (may be specified
+
    /// multiple times)
+
    #[arg(
+
        long = "author",
+
        value_name = "DID",
+
        num_args = 1..,
+
        action = clap::ArgAction::Append,
+
    )]
+
    pub(super) authors: Vec<Did>,
+

+
    /// Show only issues that you have authored
+
    #[arg(long)]
+
    pub(super) authored: bool,
}

#[derive(Parser, Debug, Default)]
@@ -296,6 +324,8 @@ impl From<EmptyArgs> for ListArgs {
        Self {
            assigned: args.assigned,
            state: ListStateArgs::from(args.state),
+
            authors: args.authors,
+
            authored: args.authored,
        }
    }
}