github.com/elopio/cli@v6.21.2-0.20160902224010-ea909d1fdb2f+incompatible/commands/v2/curl_command.go (about)

     1  package v2
     2  
     3  import (
     4  	"os"
     5  
     6  	"code.cloudfoundry.org/cli/cf/cmd"
     7  	"code.cloudfoundry.org/cli/commands"
     8  	"code.cloudfoundry.org/cli/commands/flags"
     9  )
    10  
    11  type CurlCommand struct {
    12  	RequiredArgs          flags.APIPath `positional-args:"yes"`
    13  	CustomHeaders         []string      `short:"H" description:"Custom headers to include in the request, flag can be specified multiple times"`
    14  	HTTPMethod            string        `short:"X" description:"HTTP method (GET,POST,PUT,DELETE,etc)"`
    15  	HTTPData              string        `short:"d" description:"HTTP data to include in the request body, or '@' followed by a file name to read the data from"`
    16  	IncludeReponseHeaders bool          `short:"i" description:"Include response headers in the output"`
    17  	OutputFile            string        `long:"output" description:"Write curl body to FILE instead of stdout"`
    18  	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"`
    19  }
    20  
    21  func (_ CurlCommand) Setup(config commands.Config, ui commands.UI) error {
    22  	return nil
    23  }
    24  
    25  func (_ CurlCommand) Execute(args []string) error {
    26  	cmd.Main(os.Getenv("CF_TRACE"), os.Args)
    27  	return nil
    28  }