brotab icon indicating copy to clipboard operation
brotab copied to clipboard

Add --json output flag to brotab list

Open pschmitt opened this issue 2 years ago • 3 comments

This adds a --json flag to brotab list.

The output format looks like this:

[{"id": "a.1.186","title": "Add --json output flag to brotab list by pschmitt · Pull Request #113 · balta2ar/brotab","url": "https://github.com/balta2ar/brotab/pull/113"}]

pschmitt avatar Dec 19 '23 19:12 pschmitt

Was hoping I'd find an open issue/PR re: json output. I'd find it really useful is this something you're interested in @balta2ar ?

edit: using this for now

brotab list |
  # Converts each line of tab delimited output to a JSON list
  awk -F'\t' '{
   printf "[";
    for(i=1; i<=NF; i++) {
      printf "%s\"%s\"", (i>1 ? "," : ""), $i
    }
   print "]"
  }' |
  # Creates an object to add labels
  jq -c '{ id: .[0], title: .[1], url: .[2] }'

jackmac92 avatar Oct 08 '24 23:10 jackmac92

@pschmitt It's good start for #124, but I'm sure that to continue we need support from plugin/addon backend. ;-( @jackmac92 It can be done much easier:

brotab list | \
  jq -Rc 'split("\t")|with_entries(.key|=["id","title","url"][.])'

pyhedgehog avatar Mar 18 '25 19:03 pyhedgehog

@pschmitt It's good start for #124, but I'm sure that to continue we need support from plugin/addon backend. ;-( @jackmac92 It can be done much easier:

brotab list | \
  jq -Rc 'split("\t")|with_entries(.key|=["id","title","url"][.])'

thanks!! mine was running into some issues with special chars, this looks much better

jackmac92 avatar Apr 01 '25 22:04 jackmac92