Documentation ¶
Overview ¶
Package argument contains command parameter/argument types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arg ¶
type Arg struct { // Present is whether the arg is present and a value is set. // The caller should check this field before accessing a value. Present bool // Type is the type of the arg. // This field indicates which value should be read from. Type Type // StringValue is the value of the arg, if it is a string. StringValue string // BoolValue is the value of the arg, if it is a bool. BoolValue bool // IntValue is the value of the arg, if it is an int. IntValue int64 }
Arg represents a parsed argument from a message.
type Param ¶
type Param struct { // Name is the name of the param. Name string // Type is the type of the param. // Default: String. Type Type // Required is whether the param is required. // Optional params should come last. // It is currently undefined behavior to have multiple optional params, // and to have any optional params with variadic args. Required bool // Usage is an optional human-readable string describing the param. // This is only used for the usage string, i.e. if Name:"myparam" Usage:"something", // the usage string will say $command <something> rather than $command <myparam> Usage string }
Param represents a single parameter to a command.
func (Param) Parse ¶
Parse parses the param it defines from the given message. It then returns the parsed arg and the remaining message text after parsing.
func (Param) UsageForDocString ¶
UsageForDocString returns the usage information for putting in a usage docstring, i.e. for a command named "mycommand" with a param named "myparam" with param usage of "myparamusage" $command <myparamusage>
type Type ¶
type Type uint8
Type is the type of a parameter. It affects both how the parame will be parsed to an arg, and the type it will be parsed to.
const ( // String is an parameter accepting any string, stopping at whitespace. // Type of value: string. String Type = iota + 1 // Int is an parameter accepting a single integer. // Type of value: int. Int // Boolean is an parameter accepting either true or false. // True values: "on", "true", "enabled" // False values: "off", "false", "disabled" // Type of value: bool. Boolean // Username is an parameter accepting usernames, // which are strings that can take the format username or @username. // Type of value: string. Username // Variadic represents variadic parameters. // i.e.: this type will consume the rest of the remaining parameters, // and should only be used as the terminal parameter in a list. // Type of value: string. Variadic )
Click to show internal directories.
Click to hide internal directories.