Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli/issue: Allow list arguments for empty subcommand
✗ CI failure Erik Kundt committed 7 months ago
commit 105339a8960567ea3f6dc11f6ab151961ddcf28f
parent 1314f926ce77d162dd71a442736fd9c5a4d76195
1 failed 1 pending (2 total) View logs
3 files changed +58 -1
modified crates/radicle-cli/examples/rad-issue-list.md
@@ -49,3 +49,14 @@ $ rad issue list --solved
│ ●   d87dcfe   flux capacitor underpowered   alice    (you)   good-first-issue   alice       now    │
╰────────────────────────────────────────────────────────────────────────────────────────────────────╯
```
+

+
Note: You can achieve the same by omitting the `list` subcommand, since that's the fallback when no subcommand is specified.
+

+
```
+
$ rad issue --solved
+
╭────────────────────────────────────────────────────────────────────────────────────────────────────╮
+
│ ●   ID        Title                         Author           Labels             Assignees   Opened │
+
├────────────────────────────────────────────────────────────────────────────────────────────────────┤
+
│ ●   d87dcfe   flux capacitor underpowered   alice    (you)   good-first-issue   alice       now    │
+
╰────────────────────────────────────────────────────────────────────────────────────────────────────╯
+
```
modified crates/radicle-cli/src/commands/issue.rs
@@ -41,7 +41,11 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
    };
    let repo = profile.storage.repository_mut(rid)?;

-
    let command = args.command.unwrap_or_default();
+
    // Fallback to [`Command::List`] if no subcommand is provided. Construct it
+
    // with the [`EmptyArgs`] provided, if any.
+
    let command = args
+
        .command
+
        .unwrap_or(Command::List(args.list.unwrap_or_default().into()));
    let announce = !args.no_announce && command.should_announce_for();
    let mut issues = term::cob::issues_mut(&profile, &repo)?;

modified crates/radicle-cli/src/commands/issue/args.rs
@@ -58,6 +58,10 @@ pub struct Args {
    #[arg(long, short)]
    #[clap(global = true)]
    pub(crate) verbose: bool,
+

+
    /// Arguments for the empty subcommand. Will fallback to [`Command::List`].
+
    #[clap(flatten)]
+
    pub(crate) list: Option<EmptyArgs>,
}

/// Commands to create, view, and edit Radicle issues
@@ -211,6 +215,32 @@ impl Default for Command {
    }
}

+
/// Arguments for the empty subcommand.
+
#[derive(Parser, Debug, Default)]
+
pub(crate) struct EmptyArgs {
+
    /// Filter for the list of issues that are assigned to '<DID>' (default: me)
+
    #[arg(long, name = "DID")]
+
    #[arg(default_missing_value = "me")]
+
    #[arg(num_args = 0..=1)]
+
    pub(crate) assigned: Option<Assigned>,
+

+
    /// List all issues
+
    #[arg(long, group = "state", hide = true)]
+
    all: bool,
+

+
    /// List only open issues (default)
+
    #[arg(long, group = "state", hide = true)]
+
    open: bool,
+

+
    /// List only closed issues
+
    #[arg(long, group = "state", hide = true)]
+
    closed: bool,
+

+
    /// List only solved issues
+
    #[arg(long, group = "state", hide = true)]
+
    solved: bool,
+
}
+

/// Arguments for the [`Command::List`] subcommand.
#[derive(Parser, Debug, Default)]
pub(crate) struct ListArgs {
@@ -253,6 +283,18 @@ impl From<ListArgs> for Option<State> {
    }
}

+
impl From<EmptyArgs> for ListArgs {
+
    fn from(args: EmptyArgs) -> Self {
+
        Self {
+
            assigned: args.assigned,
+
            all: args.all,
+
            open: args.open,
+
            solved: args.solved,
+
            closed: args.closed,
+
        }
+
    }
+
}
+

/// Arguments for the [`Command::Comment`] subcommand.
#[derive(Parser, Debug)]
pub(crate) struct CommentArgs {