Documentation
¶
Overview ¶
Package cmdline implements the parser for the command line arguments.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( START_COMMAND = &command{ name: "start", description: "Start the h2c process. The h2c process must be started before running any other\n" + "command. To run h2c as a background process, run '" + StartCmd + "'.", minArgs: 0, maxArgs: 0, usage: "h2c start [options]", } CONNECT_COMMAND = &command{ name: "connect", description: "Connect to a server using https.", minArgs: 1, maxArgs: 1, areArgsValid: func(args []string) bool { return regexp.MustCompile("^[^:]+(:[0-9]+)?$").MatchString(args[0]) }, usage: "h2c connect [options] <host>:<port>", } GET_COMMAND = &command{ name: "get", description: "Perform a GET request.", minArgs: 1, maxArgs: 1, areArgsValid: func(args []string) bool { return true }, usage: "h2c get [options] <path>", } SET_COMMAND = &command{ name: "set", description: "Set a header. The header will be included in any subsequent request.", minArgs: 2, maxArgs: 2, areArgsValid: func(args []string) bool { return true }, usage: "h2c set <header-name> <header-value>", } UNSET_COMMAND = &command{ name: "unset", description: "Undo 'h2c set'. The header will no longer be included in subsequent requests.\n" + "If <header-value> is omitted, all headers with <header-name> are removed.\n" + "Otherwise, only the specific value is removed but other headers with the same\n" + "name remain.", minArgs: 1, maxArgs: 2, areArgsValid: func(args []string) bool { return true }, usage: "h2c unset <header-name> [<header-value>]", } PID_COMMAND = &command{ name: "pid", description: "Show the process id of the h2c process.", minArgs: 0, maxArgs: 0, usage: "h2c pid", } STOP_COMMAND = &command{ name: "stop", description: "Stop the h2c process.", minArgs: 0, maxArgs: 0, usage: "h2c stop", } )
View Source
var ( INCLUDE_OPTION = &option{ short: "-i", long: "--include", description: "Show response headers in the output.", commands: []*command{GET_COMMAND}, hasParam: false, } TIMEOUT_OPTION = &option{ short: "-t", long: "--timeout", description: "Timeout in seconds while waiting for response.", commands: []*command{GET_COMMAND}, hasParam: true, isParamValid: func(param string) bool { return regexp.MustCompile("^[0-9]+$").MatchString(param) }, } HELP_OPTION = &option{ short: "-h", long: "--help", description: "Show this help message.", commands: []*command{START_COMMAND, CONNECT_COMMAND, GET_COMMAND, SET_COMMAND, UNSET_COMMAND, PID_COMMAND, STOP_COMMAND}, hasParam: false, } DUMP_OPTION = &option{ short: "-d", long: "--dump", description: "Dump traffic to console.", commands: []*command{START_COMMAND}, hasParam: false, } )
View Source
var StartCmd = "h2c start &"
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.