Documentation
¶
Index ¶
- func Exclusive(param *ConfigType)
- func Hidden(param *ConfigType)
- func RegisterConfigTypeForApp(appName string, name string, description string, configType interface{}, ...)
- func Required(param *ConfigType)
- func Section(section *ConfigSection) func(param *ConfigType)
- func ShowHelpIfNoArgs(pro *parseAndRunOptions)
- func Singleton(param *ConfigType)
- type Cmdline
- func (cl *Cmdline) AddConfigType(name string, description string, configType interface{}, ...)
- func (cl *Cmdline) AddRegisteredConfigTypes(appName string)
- func (cl *Cmdline) BashCompletion() error
- func (cl *Cmdline) ParseAndRun(args []string, phases []string, options ...func(*parseAndRunOptions)) error
- func (cl *Cmdline) SetOutput(out io.Writer)
- func (cl *Cmdline) ShowHelp() error
- func (cl *Cmdline) WhatRan() string
- type ConfigSection
- type ConfigType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exclusive ¶
func Exclusive(param *ConfigType)
Exclusive means if this config type exists, none other is allowed
func Hidden ¶
func Hidden(param *ConfigType)
Hidden means this config type is not listed in help or bash completion
func RegisterConfigTypeForApp ¶
func RegisterConfigTypeForApp(appName string, name string, description string, configType interface{}, options ...func(*ConfigType))
RegisterConfigTypeForApp globally registers a new config type that can be used with a named application
func Section ¶
func Section(section *ConfigSection) func(param *ConfigType)
Section means this config type should be listed within a section in the help
func ShowHelpIfNoArgs ¶
func ShowHelpIfNoArgs(pro *parseAndRunOptions)
ShowHelpIfNoArgs means that if the user provides no arguments, print the help instead of doing anything
func Singleton ¶
func Singleton(param *ConfigType)
Singleton means there can only be one of this config type
Types ¶
type Cmdline ¶
type Cmdline struct {
// contains filtered or unexported fields
}
Cmdline is a command-line processor object
func (*Cmdline) AddConfigType ¶
func (cl *Cmdline) AddConfigType(name string, description string, configType interface{}, options ...func(*ConfigType))
AddConfigType registers a new config type with the system
func (*Cmdline) AddRegisteredConfigTypes ¶
AddRegisteredConfigTypes adds the registered config types for an app to the system
func (*Cmdline) BashCompletion ¶
BashCompletion outputs a Bash script for command-line completion of the current cmdline configuration.
func (*Cmdline) ParseAndRun ¶
func (cl *Cmdline) ParseAndRun(args []string, phases []string, options ...func(*parseAndRunOptions)) error
ParseAndRun parses the command line configuration and runs the selected actions. Phases is a list of function names that will be called on each config objects. If some objects need to be configured before others, use multiple phases. Each phase is run against all objects before moving to the next phase. The return value is the name of the exclusive object that was run, if any, or an empty string if the normal, non-exclusive command ran.
type ConfigSection ¶
ConfigSection defines a section of the help output, for grouping commands together
type ConfigType ¶
type ConfigType struct {
// contains filtered or unexported fields
}
ConfigType describes a kind of parameter that can be used on the command line