Skip to content

Commit

Permalink
Merge pull request #7 from jkoelker/feat_include
Browse files Browse the repository at this point in the history
feat(output): add `include` option
  • Loading branch information
legal90 authored May 4, 2022
2 parents e3ad17b + 186c32c commit a653221
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type awsCURLFlags struct {
awsProfile string
awsService string
awsRegion string
include bool
insecure bool
proxy string
}
Expand Down Expand Up @@ -76,6 +77,7 @@ func init() {
rootCmd.PersistentFlags().StringVar(&flags.awsProfile, "profile", "", "AWS awsProfile to use for authentication")
rootCmd.PersistentFlags().StringVar(&flags.awsService, "service", "execute-api", "The name of AWS Service, used for signing the request")
rootCmd.PersistentFlags().StringVar(&flags.awsRegion, "region", "", "AWS region to use for the request")
rootCmd.PersistentFlags().BoolVarP(&flags.include, "include", "i", false, "Include the HTTP response headers in the output.")
rootCmd.PersistentFlags().BoolVarP(&flags.insecure, "insecure", "k", false, "Allow insecure server connections when using SSL")
rootCmd.PersistentFlags().StringVarP(&flags.proxy, "proxy", "x", "", `Use the specified HTTP proxy, example: -x "<[protocol://][user:password@]proxyhost[:port]>"`)

Expand Down Expand Up @@ -170,6 +172,19 @@ func runCurl(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}

if flags.include {
fmt.Printf("%s %d\n", response.Proto, response.StatusCode)

for header := range response.Header {
for _, value := range response.Header.Values(header) {
fmt.Printf("%s: %s\n", header, value)
}
}

fmt.Print("\n")
}

fmt.Println(string(content))

return nil
Expand Down

0 comments on commit a653221

Please sign in to comment.