Repository navigation
Closed
Labels
docsenhancementa request to improve CLIgh-apirelating to the gh api commandhelp wantedContributions welcome
Description
Describe the bug
"GitHub API preview
namesto request (without the "-preview" suffix)"
Means nothing to me.
I can't tell if this means that requests for certain apis will be sent without -preview. If that's the goal, then, the text should say "Send requests without -preview", but I don't think that's what's going on.
If it means "Include specific preview mime types in accepts request", then it should say something like that. My guess is that the goal is more like "GitHUB API preview names to include in request accept headers (names should omit -preview, but requests will include the suffix)."
Affected version
gh version 2.74.2 (2025-06-17)
https://github.com/cli/cli/releases/tag/v2.74.2
Steps to reproduce the behavior
- Run
gh api --help|grep -A1 preview - View the output:
gh api --help|grep -A1 preview -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 -- # Opt into GitHub API previews $ gh api --preview baptiste,nebula ...
Expected vs actual behavior
A clear and concise explanation of what preview does
- Docs improvement for
api --previewoption #3433 asked for an improvement here - Misc. docs improvements #5223 supposedly changed something, but it didn't improve things
- Note that while
`names`is present in the code, the`s are lost in the help output:
Line 279 in df5e6d9
cmd.Flags().StringSliceVarP(&opts.Previews, "preview", "p", nil, "GitHub API preview `names` to request (without the \"-preview\" suffix)")
Metadata
Metadata
Assignees
Labels
docsenhancementa request to improve CLIgh-apirelating to the gh api commandhelp wantedContributions welcome
Activity
babakks commentedon Jul 7, 2025
Thanks for opening this issue, @jsoref! 🙏
I think I agree with you that the docs is not clear about the function of the
--previewoption. Seems like what it was before #3433 was kind of clearer.I can suggest an improvement like this:
What do you think, @jsoref? Do you that's clear enough for users who are seeing it for the first time?
jsoref commentedon Jul 7, 2025
That prose is definitely better.
I'm not a fan of the
omitI think "without" is easier to understand. Omit as a verb requires an actor and this is passive prose.That still only addresses half the problem. What is a preview? Is it really only a content type response?
babakks commentedon Jul 8, 2025
I think defining a preview option as something related to a request's
Content-Typeheader field, is both confusing and too much detail. I imagine, as a user, I'd want to see there's a way to opt into upcoming API features that are not yet part of the stable release. Perhaps, this can be explained like this in the--helpdocs of the command:What do you think, @jsoref?
jsoref commentedon Jul 8, 2025
Maybe.
Let's start with the easier part:
That still leaves users the problem of discovering what previews are. Which seems incredibly challenging.
I found:
But I haven't been able to construct any query to actually find recent previews...
babakks commentedon Jul 11, 2025
Regarding the discovery of preview features, I think you should consult with API schemas:
previewskeys. As I checked forapi.github.com, there's no ongoing preview at the moment (i.e.previews: []).@previewdirective like this:@previewdirective. So, I guess there's no preview here either.As a disclaimer, I haven't tried discovering previews so far, so I maybe wrong.
babakks commentedon Jul 11, 2025
I think we're ready to put down the A/C for this issue at this stage.
Acceptance Criteria
When I run
gh api --helpThen I see the
--previewoption is clearly documented like this: