By default, the result of gh commands are output in line-based plain text format.
Some commands support passing the --json flag, which converts the output to JSON format.
Once in JSON, the output can be further formatted according to a required formatting string by
adding either the --jq or --template flag. This is useful for selecting a subset of data,
creating new data structures, displaying the data in a different format, or as input to another
command line script.
The --json flag requires a comma separated list of fields to fetch. To view the possible JSON
field names for a command omit the string argument to the --json flag when you run the command.
Note that you must pass the --json flag and field names to use the --jq or --template flags.
The --jq flag requires a string argument in jq query syntax, and will only print
those JSON values which match the query. jq queries can be used to select elements from an
array, fields from an object, create a new array, and more. The jq utility does not need
to be installed on the system to use this formatting directive. When connected to a terminal,
the output is automatically pretty-printed. To learn about jq query syntax, see:
https://jqlang.github.io/jq/manual/
The --template flag requires a string argument in Go template syntax, and will only print
those JSON values which match the query.
In addition to the Go template functions in the standard library, the following functions can be used
with this formatting directive:
autocolor: like color, but only emits color to terminals