Documentation ¶
Index ¶
- type Command
- type Group
- func (r *Group) Add(key string, cmd Command) error
- func (r *Group) Get(key string) (Command, bool)
- func (r *Group) GetClosestName(key string) (string, bool)
- func (r *Group) LongestPrefix(key string) (string, bool)
- func (r *Group) Nested() bool
- func (r *Group) Process() error
- func (r *Group) Remove(key string) (Command, error)
- func (r *Group) WalkPrefix(prefix string, fn radix.WalkFn)
- type GroupOption
- type GroupOptions
- type PlaceHolder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command interface { // Flags returns the FlagSet associated with the command. All the flags are // parsed before running the command. FlagSet() *flagset.FlagSet // Usages returns various usages that can be used for the command. Usages() []string // Help should return a long-form help text that includes the command-line // usage. A brief few sentences explaining the function of the command, and // the complete list of flags the command accepts. Help() string // Synopsis should return a one-line, short synopsis of the command. // This should be short (50 characters of less ideally). Synopsis() string // Init is called with all the args required to run a command. // This is separated from Run, to allow the preperation of a command, before // it's run. Init([]string, commands.CommandContext) error // Run should run the actual command with the given CLI instance and // command-line arguments. It should return the exit status when it is // finished. // // There are a handful of special exit codes that can return documented // behavioral changes. Run(*task.Group) }
Command represents an abstraction of command.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group holds the commands in a central repository for easy access.
func (*Group) Add ¶
Add a Command to the Group for a given key. The key is normalized to remove trailing spaces for consistency. Returns an error when inserting into the Group fails
func (*Group) Get ¶
Get returns a Command for a given key. The key is normalized to remove trailing spaces for consistency. Returns true if it was found.
func (*Group) GetClosestName ¶
GetClosestName returns the closest command to the given key
func (*Group) LongestPrefix ¶
LongestPrefix is like Get, but instead of an exact match, it will return the longest prefix match.
func (*Group) Process ¶
Process runs through the registry and fills in any commands that are required for nesting (sub commands) Returns an error if there was an issue adding any commands to the underlying storage.
type GroupOption ¶
type GroupOption func(GroupOptions)
GroupOption captures a tweak that can be applied to the Group.
func OptionPlaceHolder ¶
func OptionPlaceHolder(i PlaceHolder) GroupOption
OptionPlaceHolder allows the setting a place holder option to configure the group.
type GroupOptions ¶
type GroupOptions interface {
SetPlaceHolder(PlaceHolder)
}
GroupOptions represents a way to set optional values to a autocomplete option. The GroupOptions shows what options are available to change.
type PlaceHolder ¶
PlaceHolder is a type which is called when constructing the group and a place holder command is required.