Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add --author and --authored flags to "rad issue (list)"
Matthias Beyer committed 1 month ago
commit 9e8074690f35e40a1cb9fe36785b2bcb28ceb50b
parent 7bac17146c40b32b2ce0e27b96a555a44f3ef2ba
2 files changed +45 -0
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,
        }
    }
}