Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SimpleSuggestions ¶
SimpleSuggestions converts strings into prompt.Suggest structs
Types ¶
type Command ¶
type Command struct {
// name of the command (REQUIRED)
Cmd string
// description of the command (OPTIONAL)
Description string
// callback which gets executed (OPTIONAL)
RunCallback func(Commander, Command, []string) error
// callback to provide command argument suggestions (OPTIONAL)
ArgumentComplete func(...string) []prompt.Suggest
// commander to support nesting interfaces (OPTIONAL)
SubCommander Commander
// list of allowed first arguments (OPTIONAL)
Options []string
// validator function to validate arguments (OPTIONAL)
Validate func(args []string) bool
// contains filtered or unexported fields
}
Command represents an interactive command
type Commander ¶
type Commander interface {
// Processes commands in a loop until ctrl+d/ctrl+c is pressed. Optionally takes a list of values for the prefix string
Run(prefixArgs ...string) error
// add a new command to the current commander
AddCommand(c Command) error
// current prefix args (not threadsafe!)
PrefixArgs() []string
// set a custom writer for status messages (uses os.Stdout by default)
SetWriter(io.Writer)
}
Commander implements the cli parsing and handling
Click to show internal directories.
Click to hide internal directories.