-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Describe the bug
When running the following:
⇒ gh api notifications -F participating=true --jq '.' --template '{{range .}}{{tablerow .repository.full_name (truncate 100 .subject.title) .subject.type .reason (timeago .updated_at)}}{{end}}'
I get the following error:
the `--slurp` option is not supported with `--jq` or `--template`
Even though my command doesn't include --slurp, and it only attempts to use --jq and --template together.
This was seemingly introduced in this PR:
Lines 246 to 253 in 60f8417
| if err := cmdutil.MutuallyExclusive( | |
| "the `--slurp` option is not supported with `--jq` or `--template`", | |
| opts.Slurp, | |
| opts.FilterOutput != "", | |
| opts.Template != "", | |
| ); err != nil { | |
| return err | |
| } |
Looking closer at that code, we can see there is an error case below this that I would have expected to be shown instead:
only one of
--template,--jq,--silent, or--verbosemay be used
Lines 255 to 263 in 60f8417
| if err := cmdutil.MutuallyExclusive( | |
| "only one of `--template`, `--jq`, `--silent`, or `--verbose` may be used", | |
| opts.Verbose, | |
| opts.Silent, | |
| opts.FilterOutput != "", | |
| opts.Template != "", | |
| ); err != nil { | |
| return err | |
| } |
Steps to reproduce the behavior
See above.
Expected vs actual behavior
Ideally I would expect --jq to allow me to process the JSON, and then --template to allow me to render that processed json. I have raised a feature request for that aspect here:
If for some reason there is an actual technical limitation as to why that isn't possible, then I would at least expect the error message to accurately describe the error in what I am trying to do, and not mention a seemingly not used argument.
Logs
Paste the activity from your command line. Redact if needed.
the `--slurp` option is not supported with `--jq` or `--template`
Usage: gh api <endpoint> [flags]
Flags:
--cache duration Cache the response, e.g. "3600s", "60m", "1h"
-F, --field key=value Add a typed parameter in key=value format
-H, --header key:value Add a HTTP request header in key:value format
--hostname string The GitHub hostname for the request (default "github.com")
-i, --include Include HTTP response status line and headers in the output
--input file The file to use as body for the HTTP request (use "-" to read from standard input)
-q, --jq string Query to select values from the response using jq syntax
-X, --method string The HTTP method for the request (default "GET")
--paginate Make additional HTTP requests to fetch all pages of results
-p, --preview names GitHub API preview names to request (without the "-preview" suffix)
-f, --raw-field key=value Add a string parameter in key=value format
--silent Do not print the response body
--slurp Use with "--paginate" to return an array of all pages of either JSON arrays or objects
-t, --template string Format JSON output using a Go template; see "gh help formatting"
--verbose Include full HTTP request and response in the output