Documentation ¶
Index ¶
Constants ¶
View Source
const ( Name = "Agricola" CommandName = "ager" )
View Source
const ( ExitSuccess = 0 ExitInvalidArgs = 2 ExitCommandNotFound = 4 )
Variables ¶
This section is empty.
Functions ¶
func DefaultFlagSet ¶
Types ¶
type Command ¶
type Command struct { // Run runs the command. // The args are the arguments passed in after the command name. // The function returns the exit code of the command. Run func(cmd *Command, args []string) int // UsageLine is the one-line usage message. // The words between "ager" and the first flag or argument in the line are // taken to be the command name. UsageLine string // Short is the short description shown in the "ager help" output. Short string // Long is the long message shown in the "ager help <this-command>" output. Long string // Flag is a set of flags specific to this command. Flag *flag.FlagSet // Commands is a list of the available commands (so-called subcommands) and // other help topics for this command. // The order here is the order in which they are printed when running the // 'help' command. Commands []*Command }
A Command is an implementation of an Agricola command.
func BaseCommand ¶
func BaseCommand() *Command
func (*Command) LongName ¶
LongName returns the command's long name. Command's long name is the string between "ager" and the first arguments.
func (*Command) Lookup ¶
Lookup returns the subcommand with the given name, if any. Otherwise it returns nil. Lookup ignores subcommands that have len(c.Commands) == 0 and c.Run == nil. Such subcommands are only meant to be used as arguments to "help".
func (*Command) Name ¶
Name return the command's short name. The short name of a command is the last word in the usage line before a flag or an argument.
Click to show internal directories.
Click to hide internal directories.