Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoSubc = errors.New("Subcommand not given")
ErrNoSubc is returned when the given arguments do not contain a subcommand.
var ErrSubcNotExist = errors.New("Subcommand does not exist")
ErrSubcNotExist is returned when a subcommand that does not exist is requested.
var ErrUsage = errors.New("Usage requested")
ErrUsage is returned when usage/help is requested.
var Usage = func() { names := make([]string, len(subcommands)) i := 0 for name := range subcommands { names[i] = name i++ } fmt.Fprintf(outputWriter, "Usage of %s [%s]\n", os.Args[0], strings.Join(names, "|")) for name, f := range subcommands { fmt.Fprintf(outputWriter, "%s:\n", name) f.PrintDefaults() } }
Prints a usage message documenting all defined subcommands and their flags.
Functions ¶
func Parse ¶
Parse parses the flags for the subcommand os.Args[1]. Must be called after all flags are defined and before flags are accessed by the program. Returns the name of the requested subcommand.
func ParseArgs ¶
Parse parses the the flags of the subcommand given as the first item in the argument list. The given argument list should not include the command name. Returns the name of the parsed subcommand.
Types ¶
This section is empty.