Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Command ¶
type Command struct { // Sub is map of sub commands of the current command. The key refer to the // sub command name, and the value is it's command descriptive struct. Sub map[string]*Command // Flags is a map of flags that the command accepts. The key is the flag // name, and the value is it's predictions. In a chain of sub commands, no // duplicate flags should be defined. Flags map[string]Predictor // Args are extra arguments that the command accepts, those who are given // without any flag before. In any chain of sub commands, only one of them // should predict positional arguments. Args Predictor }
Command is an object that can be used to create complete options for a go executable that does not have a good binding to the `Completer` interface, or to use a Go program as complete binary for another executable.
func (*Command) SubCmdList ¶
type Completer ¶
type Completer interface { // SubCmdList should return the list of all sub commands of the current // command. SubCmdList() []string // SubCmdGet should return a sub command of the current command for the // given sub command name. SubCmdGet(cmd string) Completer // FlagList should return a list of all the flag names of the current // command. The flag names should not have the dash prefix. FlagList() []string // FlagGet should return completion options for a given flag. It is invoked // with the flag name without the dash prefix. The flag is not promised to // be in the command flags. In that case, this method should return a nil // predictor. FlagGet(flag string) Predictor // ArgsGet should return predictor for positional arguments of the command // line. ArgsGet() Predictor }
Completer is an interface that a command line should implement in order to get bash completion.
type PredictFunc ¶
PredictFunc is a function that implements the Predictor interface.
func (PredictFunc) Predict ¶
func (p PredictFunc) Predict(prefix string) []string
type Predictor ¶
type Predictor interface { // Predict returns prediction options for a given prefix. The prefix is // what currently is typed as a hint for what to return, but the returned // values can have any prefix. The returned values will be filtered by the // prefix when needed regardless. The prefix may be empty which means that // no value was typed. Predict(prefix string) []string }
Predictor can predict completion options.
Directories ¶
Path | Synopsis |
---|---|
Package install provide installation functions of command completion.
|
Package install provide installation functions of command completion. |
Package predict provides helper functions for completion predictors.
|
Package predict provides helper functions for completion predictors. |
Click to show internal directories.
Click to hide internal directories.