Skip to content

Add --json output flag to brotab list - #113

Open
pschmitt wants to merge 2 commits into
balta2ar:masterfrom
pschmitt:json-output
Open

Add --json output flag to brotab list#113
pschmitt wants to merge 2 commits into
balta2ar:masterfrom
pschmitt:json-output

Conversation

@pschmitt

@pschmitt pschmitt commented Dec 19, 2023

Copy link
Copy Markdown

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"}]

@jackmac92

jackmac92 commented Oct 8, 2024

Copy link
Copy Markdown

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] }'

@pyhedgehog

pyhedgehog commented Mar 18, 2025

Copy link
Copy Markdown

@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"][.])'

@jackmac92

Copy link
Copy Markdown

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants