Skip to content

Commit cb2308c

Browse files
--silent flag in api
1 parent 15a7ab6 commit cb2308c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/cmd/api/api.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type ApiOptions struct {
3434
RequestHeaders []string
3535
ShowResponseHeaders bool
3636
Paginate bool
37+
Silent bool
3738

3839
HttpClient func() (*http.Client, error)
3940
BaseRepo func() (ghrepo.Interface, error)
@@ -134,6 +135,7 @@ original query accepts an '$endCursor: String' variable and that it fetches the
134135
cmd.Flags().BoolVarP(&opts.ShowResponseHeaders, "include", "i", false, "Include HTTP response headers in the output")
135136
cmd.Flags().BoolVar(&opts.Paginate, "paginate", false, "Make additional HTTP requests to fetch all pages of results")
136137
cmd.Flags().StringVar(&opts.RequestInputFile, "input", "", "The file to use as body for the HTTP request")
138+
cmd.Flags().BoolVar(&opts.Silent, "silent", false, "Silence the output")
137139
return cmd
138140
}
139141

@@ -178,6 +180,10 @@ func apiRun(opts *ApiOptions) error {
178180
return err
179181
}
180182

183+
if opts.Silent {
184+
opts.IO.Out = ioutil.Discard
185+
}
186+
181187
hasNextPage := true
182188
for hasNextPage {
183189
resp, err := httpRequest(httpClient, method, requestPath, requestBody, requestHeaders)

0 commit comments

Comments
 (0)