--silent flag in api

This commit is contained in:
AliabbasMerchant 2020-06-29 00:15:34 +05:30
parent 15a7ab6b92
commit cb2308c077

View file

@ -34,6 +34,7 @@ type ApiOptions struct {
RequestHeaders []string
ShowResponseHeaders bool
Paginate bool
Silent bool
HttpClient func() (*http.Client, error)
BaseRepo func() (ghrepo.Interface, error)
@ -134,6 +135,7 @@ original query accepts an '$endCursor: String' variable and that it fetches the
cmd.Flags().BoolVarP(&opts.ShowResponseHeaders, "include", "i", false, "Include HTTP response headers in the output")
cmd.Flags().BoolVar(&opts.Paginate, "paginate", false, "Make additional HTTP requests to fetch all pages of results")
cmd.Flags().StringVar(&opts.RequestInputFile, "input", "", "The file to use as body for the HTTP request")
cmd.Flags().BoolVar(&opts.Silent, "silent", false, "Silence the output")
return cmd
}
@ -178,6 +180,10 @@ func apiRun(opts *ApiOptions) error {
return err
}
if opts.Silent {
opts.IO.Out = ioutil.Discard
}
hasNextPage := true
for hasNextPage {
resp, err := httpRequest(httpClient, method, requestPath, requestBody, requestHeaders)