Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli/rad: test json output
✗ CI failure WillForan committed 2 months ago
commit 16a120bafa6abf5b4a249a949ab101276a5910e7
parent cafb42e24412c8b1834506424ba5d9c2687cc833
1 failed (1 total) View logs
3 files changed +27 -11
modified crates/radicle-cli/examples/rad-issue.md
@@ -114,3 +114,24 @@ $ rad issue comment d87dcfe --edit 880fdcd -m "Even more power!"
│ Even more power!        │
╰─────────────────────────╯
```
+

+
For programmatic use or downstream customization, it may be useful to get issue lists in json format. 
+
```
+
$ rad issue list --output json
+
[
+
  {
+
    "id": "d87dcfe8c2b3200e78b128d9b959cfdf7063fefe",
+
    "state": {
+
      "status": "open"
+
    },
+
    "title": "flux capacitor underpowered",
+
    "author": "alice",
+
    "did": "(you)",
+
    "labels": [
+
      "good-first-issue"
+
    ],
+
    "assignees": [],
+
    "opened": 1671125284000
+
  }
+
]
+
```
modified crates/radicle-cli/src/commands/issue.rs
@@ -261,7 +261,7 @@ fn list<C>(
    cache: C,
    assigned: &Option<Assigned>,
    state: &Option<State>,
-
    output: &Option<OutputFormat>,
+
    output: &OutputFormat,
    profile: &profile::Profile,
    verbose: bool,
) -> anyhow::Result<()>
@@ -340,15 +340,12 @@ where
    });

    match output {
-
        Some(OutputFormat::Table) => {
+
        OutputFormat::Table => {
            print_table(all);
        }
-
        Some(OutputFormat::Json) => {
+
        OutputFormat::Json => {
            println!("{}", json::to_string_pretty(&all)?);
        }
-
        &None => {
-
            println!("Unknown ouptput format!");
-
        }
    }

    Ok(())
modified crates/radicle-cli/src/commands/issue/args.rs
@@ -248,10 +248,8 @@ pub(crate) struct ListArgs {
    pub(crate) assigned: Option<Assigned>,

    /// How to display results
-
    #[arg(long, name = "OUTPUT")]
-
    #[arg(default_missing_value = "table")]
-
    #[arg(num_args = 0..=1)]
-
    pub(crate) output: Option<OutputFormat>,
+
    #[arg(long, name = "OUTPUT", default_value = "table")]
+
    pub(crate) output: OutputFormat,

    #[clap(flatten)]
    pub(crate) state: ListStateArgs,
@@ -309,7 +307,7 @@ impl From<EmptyArgs> for ListArgs {
        Self {
            assigned: args.assigned,
            state: ListStateArgs::from(args.state),
-
            output: Some(OutputFormat::Table),
+
            output: OutputFormat::Table,
        }
    }
}