-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Describe the feature or problem you’d like to solve
When running gh search prs with --json, I want to be able to get all of the json, without needing to manually specify each key:
⇒ gh search prs "Bump node-llama-cpp author:app/dependabot" --repo jehna/humanify --sort=created --order=asc --json | jq | subl
Specify one or more comma-separated fields for `--json`:
assignees
author
authorAssociation
body
closedAt
commentsCount
createdAt
id
isDraft
isLocked
isPullRequest
labels
number
repository
state
title
updatedAt
urlThere doesn't even seem to be a 'magic field keyword' to imply "give me everything" currently:
⇒ gh search prs "Bump node-llama-cpp author:app/dependabot" --repo jehna/humanify --sort=created --order=asc --json '*' | jq | subl
Unknown JSON field: "*"
Available fields:
..snip..If I omit --json entirely, it doesn't give me it in json:
⇒ gh search prs "Bump node-llama-cpp author:app/dependabot" --repo jehna/humanify --sort=created --order=asc | cat
jehna/humanify 25 merged Bump node-llama-cpp from 3.0.0-beta.42 to 3.0.0-beta.44 dependencies 2024-08-11T18:55:54Z
jehna/humanify 110 closed Bump node-llama-cpp from 3.0.0-beta.44 to 3.0.0-beta.45 dependencies 2024-09-23T02:16:40Z
..snip..Apparently I can't specify --jq without also specifying --json, so I can't even attempt to hack around it by passing something like --jq '.':
⇒ gh search prs "Bump node-llama-cpp author:app/dependabot" --repo jehna/humanify --sort=created --order=asc --jq '.'
cannot use `--jq` without specifying `--json`Proposed solution
- When I pass
--jsonwith no fields, it should give me the unfiltered json. - When I pass
--jq, but haven't specified--jsonexplicitly; it should default to implying that--jsonwas passed with no filter, and return the full json, which then has the--jqpattern applied to it. - When I pass
--jsonwith fields, it should continue to work as it currently does
A less desirable potential alternative is that there is some 'magic fields keyword' that implies 'give me the json unfiltered'; though personally, I would rather be able to just pass --json without any fields for that; or not even have to and have --jq imply it.
Additional context
Relevant snippets from the help text:
⇒ gh search prs -h
..snip..
-q, --jq expression Filter JSON output using a jq expression
--json fields Output JSON with the specified fields
..snip..
-t, --template string Format JSON output using a Go template; see "gh help formatting"
..snip..
JSON FIELDS
assignees, author, authorAssociation, body, closedAt, commentsCount, createdAt,
id, isDraft, isLocked, isPullRequest, labels, number, repository, state, title,
updatedAt, url
..snip..
Tangentially Related
There have been a number of other json/jq Quality of Life issues I've opened recently; and some awesome PRs associated with some of them, made by @heaths . I'm not sure of the deeper specifics as to whether any of them would crossover with this at an implementation level; but from a user perspective, it's kind of weird/confusing feeling when different CLI commands seem to handle json/jq differently.