github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/command/v2/curl_command.go (about) 1 package v2 2 3 import ( 4 "os" 5 6 flags "github.com/jessevdk/go-flags" 7 8 "code.cloudfoundry.org/cli/cf/cmd" 9 "code.cloudfoundry.org/cli/command" 10 "code.cloudfoundry.org/cli/command/flag" 11 ) 12 13 type CurlCommand struct { 14 RequiredArgs flag.APIPath `positional-args:"yes"` 15 CustomHeaders []string `short:"H" description:"Custom headers to include in the request, flag can be specified multiple times"` 16 HTTPMethod string `short:"X" description:"HTTP method (GET,POST,PUT,DELETE,etc)"` 17 HTTPData flag.FilenameWithAt `short:"d" description:"HTTP data to include in the request body, or '@' followed by a file name to read the data from"` 18 IncludeReponseHeaders bool `short:"i" description:"Include response headers in the output"` 19 OutputFile flags.Filename `long:"output" description:"Write curl body to FILE instead of stdout"` 20 usage interface{} `usage:"CF_NAME curl PATH [-iv] [-X METHOD] [-H HEADER] [-d DATA] [--output FILE]\n\n By default 'CF_NAME curl' will perform a GET to the specified PATH. If data\n is provided via -d, a POST will be performed instead, and the Content-Type\n will be set to application/json. You may override headers with -H and the\n request method with -X.\n\n For API documentation, please visit http://apidocs.cloudfoundry.org.\n\nEXAMPLES:\n CF_NAME curl \"/v2/apps\" -X GET -H \"Content-Type: application/x-www-form-urlencoded\" -d 'q=name:myapp'\n CF_NAME curl \"/v2/apps\" -d @/path/to/file"` 21 } 22 23 func (_ CurlCommand) Setup(config command.Config, ui command.UI) error { 24 return nil 25 } 26 27 func (_ CurlCommand) Execute(args []string) error { 28 cmd.Main(os.Getenv("CF_TRACE"), os.Args) 29 return nil 30 }