Documentation ¶
Index ¶
- type FlatSection
- type HelpShort
- type Name
- type SectionIterator
- type SectionMap
- type SectionOpt
- func Command(name command.Name, helpShort command.HelpShort, action command.Action, ...) SectionOpt
- func ExistingCommand(name command.Name, value command.Command) SectionOpt
- func ExistingFlag(name flag.Name, value flag.Flag) SectionOpt
- func ExistingFlags(flagMap flag.FlagMap) SectionOpt
- func ExistingSection(name Name, value SectionT) SectionOpt
- func Flag(name flag.Name, helpShort flag.HelpShort, empty value.EmptyConstructor, ...) SectionOpt
- func Footer(footer string) SectionOpt
- func HelpLong(helpLong string) SectionOpt
- func Section(name Name, helpShort HelpShort, opts ...SectionOpt) SectionOpt
- type SectionT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FlatSection ¶ added in v0.0.13
type FlatSection struct { // InheritedFlags contains combined flags from ancestor sections InheritedFlags flag.FlagMap // Path to this section Path []Name // Sec is this section Sec SectionT }
FlatSection represents a section and relevant parent information
type SectionIterator ¶ added in v0.0.13
type SectionIterator struct {
// contains filtered or unexported fields
}
SectionIterator is used in BreadthFirst. See BreadthFirst docs
func (*SectionIterator) HasNext ¶ added in v0.0.13
func (s *SectionIterator) HasNext() bool
HasNext is used in BreadthFirst. See BreadthFirst docs
func (*SectionIterator) Next ¶ added in v0.0.13
func (s *SectionIterator) Next() FlatSection
HasNext is used in BreadthFirst. See BreadthFirst docs
type SectionMap ¶
SectionMap holds Sections - used by other Sections
func (SectionMap) Empty ¶ added in v0.0.13
func (fm SectionMap) Empty() bool
func (SectionMap) SortedNames ¶ added in v0.0.13
func (fm SectionMap) SortedNames() []Name
type SectionOpt ¶
type SectionOpt func(*SectionT)
SectionOpt customizes a Section on creation
func Command ¶
func Command(name command.Name, helpShort command.HelpShort, action command.Action, opts ...command.CommandOpt) SectionOpt
Command creates a Command and adds it underneath this Section. Panics if a Command with the same name already exists
func ExistingCommand ¶
func ExistingCommand(name command.Name, value command.Command) SectionOpt
ExistingCommand adds an existing Command underneath this Section. Panics if a Command with the same name already exists
func ExistingFlag ¶
func ExistingFlag(name flag.Name, value flag.Flag) SectionOpt
ExistingFlag adds an existing Flag to be made availabe to subsections and subcommands. Panics if the flag name doesn't start with '-' or a flag with the same name exists already
func ExistingFlags ¶
func ExistingFlags(flagMap flag.FlagMap) SectionOpt
func ExistingSection ¶
func ExistingSection(name Name, value SectionT) SectionOpt
ExistingSection adds an existing Section underneath this Section. Panics if a Section with the same name already exists
func Flag ¶
func Flag(name flag.Name, helpShort flag.HelpShort, empty value.EmptyConstructor, opts ...flag.FlagOpt) SectionOpt
Flag creates a Flag and makes it availabe to subsections and subcommands. Panics if the flag name doesn't start with '-' or a flag with the same name exists already
func Footer ¶
func Footer(footer string) SectionOpt
Footer adds an optional help string to this Section
func HelpLong ¶
func HelpLong(helpLong string) SectionOpt
HelpLong adds an optional help string to this Section
func Section ¶
func Section(name Name, helpShort HelpShort, opts ...SectionOpt) SectionOpt
Section creates a Section and adds it underneath this Section. Panics if a Section with the same name already exists
type SectionT ¶
type SectionT struct { // Flags holds flags available to this Section and all subsections and Commands Flags flag.FlagMap // Commands holds the Commands under this Section Commands command.CommandMap // Sections holds the Sections under this Section Sections SectionMap // HelpShort is a required one-line descripiton of this section HelpShort HelpShort // HelpLong is an optional longer description of this section HelpLong string Footer string }
Sections are like "folders" for Commmands. They should have noun names. Sections should not be created in place - New/ExistingSection/Section functions. SectionT is the type name because we need the more user-visible `Section` as a function name.
func (*SectionT) BreadthFirst ¶ added in v0.0.13
func (sec *SectionT) BreadthFirst(path []Name) SectionIterator
Breadthfirst returns a SectionIterator that yields sections sorted alphabetically breadth-first by path. Yielded sections should never be modified - they can share references to the same inherited flags SectionIterator's Next() method panics if two sections in the path have flags with the same name. Breadthfirst is used by app.Validate and help.AllCommandCommandHelp/help.AllCommandSectionHelp