Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PredictSet ¶
PredictSet predicts the values from the given set
Types ¶
type Args ¶
Args bundles user-supplied implementations of the respective interfaces into an Arguments implementation.
type Arguments ¶
Arguments is used to validate and complete positional arguments. Use `Args()` to create an instance from functions.
func ArgsNone ¶
func ArgsNone() Arguments
ArgsNone checks that no arguments were given, and disables predictions.
type Command ¶
type Command struct { // Usage line. First word must be the command name, everything else is // displayed as-is. Use string // Aliases define alternative names for a command Aliases []string // Short help text, used for overviews Short string // Long help text, used for full help pages. `Short` is used as a fallback // if unset. Long string // Version of the application. Only used on the root command Version string // Run is the action that is run when this command is invoked. // The error is returned as-is from `Execute()`. Run func(cmd *Command, args []string) error // Validation + Completion // // Predict contains Predictors for flags. Defaults to // `complete.PredictSomething` if unset. // Use the flags name (not shorthand) as the key. Predictors map[string]complete.Predictor // Args is used to validate and complete positional arguments Args Arguments // contains filtered or unexported fields }
Command represents a (sub)command of the application. Either `Run()` must be defined, or subcommands added using `AddCommand()`. These are also mutually exclusive.
func (*Command) AddCommand ¶
AddCommand adds the supplied commands as subcommands. This command is set as the parent of the new children.
func (*Command) Execute ¶
Execute runs the application. It should be run on the most outer level command. The error return value is used for both, application errors but also help texts.
type ErrHelp ¶
type ErrHelp struct { Message string // contains filtered or unexported fields }
ErrHelp wraps an actual error, showing the usage of the command afterwards
type PredictFunc ¶
type PredictFunc = complete.PredictFunc
PredictFunc allows to use an ordinary func as an Predictor
type ValidateFunc ¶
ValidateFunc allows to use an ordinary func as an Validator
func ValidateExact ¶
func ValidateExact(n int) ValidateFunc
ValidateExact checks that exactly n arguments were given
func ValidateMin ¶ added in v0.2.0
func ValidateMin(n int) ValidateFunc
ValidateMin checks that at least n arguments were given
func ValidateRange ¶ added in v0.2.0
func ValidateRange(n, m int) ValidateFunc
ValidateRange checks that between n and m arguments (inclusive) were given
func ValidateSet ¶
func ValidateSet(set ...string) ValidateFunc
ValidateSet checks that the given single argument is part of the set.
func (ValidateFunc) Validate ¶
func (v ValidateFunc) Validate(args []string) error
Validate wrap the underlying function