You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow --jq and --template to be used together in gh api #10261
Describe the feature or problem you’d like to solve
When using gh api, I would like to be able to use the expressive power of --jq to manipulate/filter the JSON response data, and then --template to render it, but currently that doesn't seem to be allowed:
If it were possible to pass both --jq and --template together, then users would have more expressive ability to manipulate API response data through gh api without having to resort to moving to external tools/processing.
In particular, this would allow users to use --jq's deeper functionality for manipulation, while leveraging --template's simple/clean syntax for rendering the output.
Another potentially useful feature/workaround/alternative (which I haven't checked too deeply to see if it is currently possible), would being able to pipe arbitrary json to the gh CLI, and then process that with --template. That would then allow us to do something like:
There seems to be some workarounds discussed already in that thread - I highlighted what I thought was the most applicable below.
Another potentially useful feature/workaround/alternative (which I haven't checked too deeply to see if it is currently possible), would being able to pipe arbitrary json to the gh CLI, and then process that with --template. That would then allow us to do something like:
@BagToad I haven't read the full thread yet, so I may have missed something, but at least from reading the main post, it sounds like they want to be able to get the --jq and --template output separately. Whereas I want the --jq processing to happen, and then the --template to be applied to that processed json, outputting only the final --template result.
Though I guess reading further, it sounds like it does coalesce to what I am requesting here.. so yeah, that should be fine :)
(Though I wonder if that nuance might be able to be added to the title, or the first post or similar; as I would have bypassed it completely based on the title/original post content)
Activity
0xdevalias commentedon Jan 17, 2025
Another potentially useful feature/workaround/alternative (which I haven't checked too deeply to see if it is currently possible), would being able to pipe arbitrary json to the
ghCLI, and then process that with--template. That would then allow us to do something like:0xdevalias commentedon Jan 17, 2025
You can see a real world example of why it would be nice to combine
--jqwith--templatein #659 (comment)[bin] add gh-notifications helper script
[config] gh: add alias: notifications -> call $HOME/.dotfiles/bin/gh-…
BagToad commentedon Jan 17, 2025
👋 Hey @0xdevalias - thanks for this!
I think this may be a duplicate of:
There seems to be some workarounds discussed already in that thread - I highlighted what I thought was the most applicable below.
From #8415, I suspect https://github.com/heaths/gh-merge-json may be what you're looking for 😁
Please let me know if I misunderstood and we can re-open this issue ❤
0xdevalias commentedon Jan 18, 2025
@BagToad I haven't read the full thread yet, so I may have missed something, but at least from reading the main post, it sounds like they want to be able to get the
--jqand--templateoutput separately. Whereas I want the--jqprocessing to happen, and then the--templateto be applied to that processed json, outputting only the final--templateresult.Though I guess reading further, it sounds like it does coalesce to what I am requesting here.. so yeah, that should be fine :)
(Though I wonder if that nuance might be able to be added to the title, or the first post or similar; as I would have bypassed it completely based on the title/original post content)
@BagToad That definitely sounds like it will do the trick for that need. Thanks :)