From ad0252e845ce2ac5694531e5e93060a4dee09bcd Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Fri, 31 Oct 2025 13:35:20 +0000 Subject: [PATCH 1/2] docs(api): mention use of `@` and `@-` for `--field` Signed-off-by: Babak K. Shandiz --- pkg/cmd/api/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/api/api.go b/pkg/cmd/api/api.go index fb16427b6..f01e1f861 100644 --- a/pkg/cmd/api/api.go +++ b/pkg/cmd/api/api.go @@ -280,7 +280,7 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command cmd.Flags().StringVar(&opts.Hostname, "hostname", "", "The GitHub hostname for the request (default \"github.com\")") cmd.Flags().StringVarP(&opts.RequestMethod, "method", "X", "GET", "The HTTP method for the request") - cmd.Flags().StringArrayVarP(&opts.MagicFields, "field", "F", nil, "Add a typed parameter in `key=value` format") + cmd.Flags().StringArrayVarP(&opts.MagicFields, "field", "F", nil, "Add a typed parameter in `key=value` format (use \"@\" or \"@-\" to read value from file or stdin)") 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, "Opt into GitHub API previews (names should omit '-preview')") From ba5c9af9576487b0add3d59c18db8007dae6d69e Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Fri, 31 Oct 2025 13:44:17 +0000 Subject: [PATCH 2/2] docs(api): add example for `--input` option Signed-off-by: Babak K. Shandiz --- pkg/cmd/api/api.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/cmd/api/api.go b/pkg/cmd/api/api.go index f01e1f861..53c07f3f0 100644 --- a/pkg/cmd/api/api.go +++ b/pkg/cmd/api/api.go @@ -143,6 +143,9 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command # Add parameters to a GET request $ gh api -X GET search/issues -f q='repo:cli/cli is:open remote' + # Use a JSON file as request body + $ gh api repos/{owner}/{repo}/rulesets --input file.json + # Set a custom HTTP header $ gh api -H 'Accept: application/vnd.github.v3.raw+json' ...