Skip to content

Improve api --preview docs #11274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improve api --preview docs
Signed-off-by: Josh Soref <[email protected]>
  • Loading branch information
jsoref committed Jul 11, 2025
commit 4687f3312d1cb0bb5f90863cca7d0961bb93c56d
9 changes: 8 additions & 1 deletion pkg/cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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")
Expand Down
Loading