github.com/liamawhite/cli-with-i18n@v6.32.1-0.20171122084555-dede0a5c3448+incompatible/command/v2/curl_command.go (about)

     1  package v2
     2  
     3  import (
     4  	"os"
     5  
     6  	"github.com/liamawhite/cli-with-i18n/cf/cmd"
     7  	"github.com/liamawhite/cli-with-i18n/command"
     8  	"github.com/liamawhite/cli-with-i18n/command/flag"
     9  )
    10  
    11  type CurlCommand struct {
    12  	RequiredArgs          flag.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              flag.PathWithAt `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            flag.Path       `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 command.Config, ui command.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  }