cli/rad: issue list --output json
json output added to put customized output into the users’ control.
Issue: 2e51b37 Topic: https://radicle.zulipchat.com/#narrow/channel/369873-Support/topic/.60rad.20issue.20list.60.20as.20tsv.20or.20json.3F/with/538037563
Refactored list command to collect new IssueSummary struct via map.
Move table printing into dedicated function.
Dispatched on new output format option (OutputFormat).
Currently, options are ‘table’ or new ‘json’ via serde_json.
An alternative to this code might be using cache.db with sqlite3.
But getting author and assignee aliases from DID isn’t easy (?)
sqlite3 $(rad self --home)/cobs/cache.db "
select json_group_array(json_insert(json_extract(issue,'$'),'$.id',id))
from issues
where repo = '$(rad .)'"|
jq '.[] |
[.id, .state.status,
([(.thread.comments[]|[(.edits[0].timestamp/1000|todate),.author])]|sort[0]),
.title]|
flatten(1) | @tsv' -r
1 file changed
+100
-37
f1c7c986
→
28da0f88
modified crates/radicle-cli/src/commands/issue.rs
@@ -6,6 +6,7 @@ use std::ffi::OsString;
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -21,6 +22,8 @@ use radicle::storage;
|
|
|
|
|
|
| + | |
| + | |
|
|
|
|
|
@@ -41,7 +44,7 @@ Usage
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -65,6 +68,12 @@ Label options
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -95,6 +104,14 @@ pub enum OperationName {
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -154,6 +171,7 @@ pub enum Operation {
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -197,6 +215,7 @@ impl Args for Options {
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -231,6 +250,16 @@ impl Args for Options {
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -296,6 +325,7 @@ impl Args for Options {
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -453,7 +483,9 @@ impl Args for Options {
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -677,8 +709,8 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
|
|
|
@@ -715,10 +747,23 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -758,74 +803,92 @@ where
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
|
| - | |
| - | |
| - | |
| + | |
| + | |
| + | |
|
|
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
|
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
|
|
|
|
|
|
|
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| + | |
|
|
| - | |
| + | |
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
| - | |
| - | |
| - | |
| - | |
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
| - | |
| + | |
|
|
| - | |
| + | |
|
|
|
|
|
|
|
|
|
|
|
|
| - | |
| - | |
|
|
|
|
|