-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support pretty-printing and colorizing JSON responses for the api
command when using jq
expressions
#3994
Comments
This would be great to have, not only are colors and pretty-printing features of $ gh api repos/{owner}/{repo}/compare/prod...main | jq '.commits[].commit | {author: .author.name, message}'
$ gh api repos/{owner}/{repo}/compare/prod...main --jq '.commits.[].commit | {author: .author.name, message}' |
This requires two changes:
Because |
My PR implementation enables the feature when connected to a TTY; this allows existing tools that expect the output to be compact to still work when piping the output. |
|
Describe the feature or problem you’d like to solve
When using the
api
command with ajq
expression, the CLI currently does not pretty-print nor colorize the post-processed response, even thoughjq
already supports both features. The resulting output nowadays is a compact JSON representation that may be quite difficult to interpret visually.Proposed solution
This would be a nice to have when you are exploring the GitHub API leveraging the client during the development of integrations with the GitHub API.
A possibility would be to have the means to enable these behaviors -in case they should not be enabled by default for other reasons (i.e., performance or safety)- via additional
api
command flags:$ gh api --jq <expression>
--prettyprint --colorize
<path>
The text was updated successfully, but these errors were encountered: