Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Command ¶
type Command struct { // Action to run when command is invoked Action Action // Parsed Flags Flags flag.FlagMap Footer string // HelpLong is an optional longer description HelpLong string // HelpShort is a required one-line description HelpShort HelpShort }
A Command will run code for you! The name of a Command should probably be a verb - add , edit, run, ... A Command should not be constructed directly. Use Command / New / ExistingCommand functions
type CommandMap ¶
A CommandMap holds Commands and is used by Sections
func (CommandMap) Empty ¶ added in v0.0.13
func (fm CommandMap) Empty() bool
func (CommandMap) SortedNames ¶ added in v0.0.13
func (fm CommandMap) SortedNames() []Name
type CommandOpt ¶
type CommandOpt func(*Command)
A CommandOpt customizes a Command
func Flag ¶
func Flag(name flag.Name, value flag.Flag) CommandOpt
Flag adds an existing flag to a Command. It panics if a flag with the same name exists
func FlagMap ¶ added in v0.0.28
func FlagMap(flagMap flag.FlagMap) CommandOpt
FlagMap adds existing flags to a Command. It panics if a flag with the same name exists
func Footer ¶
func Footer(footer string) CommandOpt
Footer adds an Help string to the command - useful from a help function
func HelpLong ¶
func HelpLong(helpLong string) CommandOpt
HelpLong adds an Help string to the command - useful from a help function
type Context ¶ added in v0.0.14
type Context struct { AppName string // Context to smuggle user-defined state (i.e., not flags) into an Action. I use this for mocks when testing Context context.Context Flags PassedFlags // Path passed either to a command or a section. Does not include executable name (os.Args[0]) Path []string Stderr *os.File Stdout *os.File // Version of this app Version string }
Context holds everything a command needs.
type PassedFlags ¶ added in v0.0.14
type PassedFlags map[string]interface{} // This can just stay a string for the convenience of the user.
PassedFlags holds a map of flag names to flag Values