Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Main ¶
func Main()
Main implements the main function of the caddy command. Call this if Caddy is to be the main() of your program.
func RegisterCommand ¶
func RegisterCommand(cmd Command)
RegisterCommand registers the command cmd. cmd.Name must be unique and conform to the following format:
- lowercase
- alphanumeric and hyphen characters only
- cannot start or end with a hyphen
- hyphen cannot be adjacent to another hyphen
This function panics if the name is already registered, if the name does not meet the described format, or if any of the fields are missing from cmd.
This function should be used in init().
Types ¶
type Command ¶
type Command struct { // The name of the subcommand. Must conform to the // format described by the RegisterCommand() godoc. // Required. Name string // Func is a function that executes a subcommand using // the parsed flags. It returns an exit code and any // associated error. // Required. Func CommandFunc // Usage is a brief message describing the syntax of // the subcommand's flags and args. Use [] to indicate // optional parameters and <> to enclose literal values // intended to be replaced by the user. Do not prefix // the string with "caddy" or the name of the command // since these will be prepended for you; only include // the actual parameters for this command. Usage string // Short is a one-line message explaining what the // command does. Should not end with punctuation. // Required. Short string // Long is the full help text shown to the user. // Will be trimmed of whitespace on both ends before // being printed. Long string // Flags is the flagset for command. Flags *flag.FlagSet }
Command represents a subcommand. Name, Func, and Short are required.
type CommandFunc ¶
CommandFunc is a command's function. It runs the command and returns the proper exit code along with any error that occurred.
type Flags ¶
Flags wraps a FlagSet so that typed values from flags can be easily retrieved.
func (Flags) Bool ¶
Bool returns the boolean representation of the flag given by name. It returns false if the flag is not a boolean type. It panics if the flag is not in the flag set.
func (Flags) Duration ¶
Duration returns the duration representation of the flag given by name. It returns false if the flag is not a duration type. It panics if the flag is not in the flag set.
func (Flags) Float64 ¶
Float64 returns the float64 representation of the flag given by name. It returns false if the flag is not a float64 type. It panics if the flag is not in the flag set.