Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Argument ¶
type Argument struct { // When the argument is parsed from the input, the argument // text must match the label in order to invoke the command. Label string `yaml:"label"` // If applicable, any options that are required for the // command. Options []Option `yaml:"options"` // The function performed when this command is invoked. // The options will be passed to this function as Flags. ExecFunc string `yaml:"execFunc"` // (optional) help message for this argument. HelpMsg string `yaml:"help"` // contains filtered or unexported fields }
Argument is the word, words or set of consecutive characters, that follow the command. If the command has no arguments, Label should be set as an empty string.
type Command ¶
type Command struct { // When the command is parsed from the input, the command // text must match the label in order to invoke the command. Label string `yaml:"label"` // Any arguments that are required for the command. // For a command without any arguments, the argument label // should be an empty string. Arguments []Argument `yaml:"arguments"` // contains filtered or unexported fields }
Command is the first word or set of consecutive characters.
type Config ¶
type Config struct { // The output to the CLI to prompt input from the user. Prompt string `yaml:"prompt"` // The commands that are configured. Commands []Command `yaml:"commands"` // The function performed when the CLI is intialised. // The output from this function will appear before // any other output in the CLI. InitFunc string `yaml:"initFunc"` // The function performed when the CLI is terminated. // This function's output will be the last output to // appear in the CLI before it closes. ExitFunc string `yaml:"exitFunc"` // The CLI command used to trigger an exit. ExitCmd string `yaml:"exitCmd"` // The CLI command used to print a help message. HelpCmd string `yaml:"helpCmd"` // contains filtered or unexported fields }
Config represents the all the config options required to run the CLI.
func LoadConfig ¶
LoadConfig extracts the config from the given yaml file and unmarshals it into a Config. Any errors reading the file or unmarshaling the file will be returned.
type Flags ¶
type Flags struct {
// contains filtered or unexported fields
}
Flags stores data for the options and variables for a command.
type Option ¶
type Option struct { // Name of the variable that will be used as a key for // a flag mapping when used in a action function. Label string `yaml:"label"` // Short name, single dash (–) followed by a signle // character. Short string `yaml:"short"` // Long name, double dash (--) followed by a // descriptive name. Long string `yaml:"long"` // (optional) if this option requires a variable, // it should be defined here. Variable *Variable `yaml:"variable"` // (optional) help message for this option. HelpMsg string `yaml:"help"` }
Option is a character, set of consecutive characters, or a word that follows the command and any arguments. Options are preceded by an dash (–).
type Variable ¶
type Variable struct { // Name of the variable that will be used as a key for // a variable mapping when used in a action function. // It will also be used as the variable placeholder in // the help messages. Label string `yaml:"label"` // Whether the option for this variable is required // for the command. Required bool `yaml:"required"` // (optional) The default value for the variable Default string `yaml:"default"` }
Variable is any set of consecutive characters or word that follows an option.