Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cli ¶
type Cli interface {
// AddBaseCommand adds a command on the root (base) level of the command tree. Use the *Command return value to add
// additional subcommands. Parameters: use (command mnemonic), shortInfo (short info shown in help),
// longDescription (long description shown in help), runFunction (function to be run when command is invoked)
AddBaseCommand(use string, shortInfo string, longDescription string, runFunction func()) Command
// Run starts the cli, parsing the given os.Args and executing the matching command
Run() error
// GetRootCommand returns the root top level command, directly as cobra.Command which is the library used
// under the hood.
GetRootCommand() *cobra.Command
// OnInitialize sets the passed function to be run when each command is called. Consider this like a global initializer
// hook.
OnInitialize(initFunction func())
SetDefaultCommand(command string)
}
type Command ¶
type Command interface {
// AddCommand add a subcommand to this command. Parameters: use (command mnemonic), shortInfo (short info shown in help),
// longDescription (long description shown in help), runFunction (function to be run when command is invoked)
AddCommand(use string, shortInfo string, longDescription string, runFunction func()) Command
// AddParameterString adds a string parameter to the command. Parameter value can be read using viper.GetString method.
// Parameter "shorthand" can only be one letter string!
AddParameterString(name string, defaultValue string, required bool, shorthand string, description string)
// AddParameterBool adds a boolean parameter to the command. Parameter value can be read using viper.GetBool method.
// Parameter "shorthand" can only be one letter string!
AddParameterBool(name string, defaultValue bool, required bool, shorthand string, description string)
// AddParameterInt adds an integer parameter to the command. Parameter value can be read using viper.GetInt method.
// Parameter "shorthand" can only be one letter string!
AddParameterInt(name string, defaultValue int, required bool, shorthand string, description string)
// AddPersistentParameterString adds a string parameter to the command, which will also be available to all sub commands
// as well. Value of the parameter can be read using viper.GetString method. Parameter "shorthand" can only be one letter string!
AddPersistentParameterString(name string, defaultValue string, required bool, shorthand string, description string)
// AddPersistentParameterBool adds a boolean parameter to the command, which will also be available to all sub commands
// as well. Value of the parameter can be read using viper.GetBool method. Parameter "shorthand" can only be one letter string!
AddPersistentParameterBool(name string, defaultValue bool, required bool, shorthand string, description string)
// AddPersistentParameterInt adds an integer parameter to the command, which will also be available to all sub commands
// as well. Value of the parameter can be read using viper.GetInt method. Parameter "shorthand" can only be one letter string!
AddPersistentParameterInt(name string, defaultValue int, required bool, shorthand string, description string)
// GetCobraCommand returns the underlying cobra.Command for this command (framework used under the hood)
GetCobraCommand() *cobra.Command
}
Command represents any command instantiated through Cli. Keep these instances (assign them to variables), so that you can add additional sub-commands or parameters.
Click to show internal directories.
Click to hide internal directories.