Merge pull request #11274 from jsoref/issue-11239

Improve `api` `--preview` docs
This commit is contained in:
William Martin 2025-07-23 10:42:13 +02:00 committed by GitHub
commit 43e76099a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -85,6 +85,13 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command
any value that contains %[1]s{...}%[1]s in quotes to prevent the shell from
applying special meaning to curly braces.
The %[1]s-p/--preview%[1]s flag enables opting into previews, which are feature-flagged,
experimental API endpoints or behaviors. The API expects opt-in via the %[1]sAccept%[1]s
header with format %[1]sapplication/vnd.github.<preview-name>-preview+json%[1]s and this
command facilitates that via %[1]s--preview <preview-name>%[1]s. To send a request for
the corsair and scarlet witch previews, you could use %[1]s-p corsair,scarlet-witch%[1]s
or %[1]s--preview corsair --preview scarlet-witch%[1]s.
The default HTTP request method is %[1]sGET%[1]s normally and %[1]sPOST%[1]s if any parameters
were added. Override the method with %[1]s--method%[1]s.
@ -276,7 +283,7 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command
cmd.Flags().StringArrayVarP(&opts.MagicFields, "field", "F", nil, "Add a typed parameter in `key=value` format")
cmd.Flags().StringArrayVarP(&opts.RawFields, "raw-field", "f", nil, "Add a string parameter in `key=value` format")
cmd.Flags().StringArrayVarP(&opts.RequestHeaders, "header", "H", nil, "Add a HTTP request header in `key:value` format")
cmd.Flags().StringSliceVarP(&opts.Previews, "preview", "p", nil, "GitHub API preview `names` to request (without the \"-preview\" suffix)")
cmd.Flags().StringSliceVarP(&opts.Previews, "preview", "p", nil, "Opt into GitHub API previews (names should omit '-preview')")
cmd.Flags().BoolVarP(&opts.ShowResponseHeaders, "include", "i", false, "Include HTTP response status line and headers in the output")
cmd.Flags().BoolVar(&opts.Slurp, "slurp", false, "Use with \"--paginate\" to return an array of all pages of either JSON arrays or objects")
cmd.Flags().BoolVar(&opts.Paginate, "paginate", false, "Make additional HTTP requests to fetch all pages of results")