Documentation ¶
Overview ¶
Package clir provides a simple API for creating command line apps
Index ¶
- type Action
- type Cli
- func (c *Cli) Action(callback Action) *Cli
- func (c *Cli) AddCommand(command *Command)
- func (c *Cli) AddFlags(flags interface{}) *Cli
- func (c *Cli) BoolFlag(name, description string, variable *bool) *Cli
- func (c *Cli) DefaultCommand(defaultCommand *Command) *Cli
- func (c *Cli) IntFlag(name, description string, variable *int) *Cli
- func (c *Cli) LongDescription(longdescription string) *Cli
- func (c *Cli) Name() string
- func (c *Cli) NewSubCommand(name, description string) *Command
- func (c *Cli) NewSubCommandFunction(name string, description string, test interface{}) *Cli
- func (c *Cli) NewSubCommandInheritFlags(name, description string) *Command
- func (c *Cli) OtherArgs() []string
- func (c *Cli) PostRun(callback func(*Cli) error)
- func (c *Cli) PreRun(callback func(*Cli) error)
- func (c *Cli) PrintBanner()
- func (c *Cli) PrintHelp()
- func (c *Cli) Run(args ...string) error
- func (c *Cli) SetBannerFunction(fn func(*Cli) string)
- func (c *Cli) SetErrorFunction(fn func(string, error) error)
- func (c *Cli) ShortDescription() string
- func (c *Cli) StringFlag(name, description string, variable *string) *Cli
- func (c *Cli) Version() string
- type Command
- func (c *Command) Action(callback Action) *Command
- func (c *Command) AddCommand(command *Command)
- func (c *Command) AddFlags(optionStruct interface{}) *Command
- func (c *Command) BoolFlag(name, description string, variable *bool) *Command
- func (c *Command) BoolsFlag(name, description string, variable *[]bool) *Command
- func (c *Command) Float32Flag(name, description string, variable *float32) *Command
- func (c *Command) Float32sFlag(name, description string, variable *[]float32) *Command
- func (c *Command) Float64Flag(name, description string, variable *float64) *Command
- func (c *Command) Float64sFlag(name, description string, variable *[]float64) *Command
- func (c *Command) Hidden()
- func (c *Command) Int16Flag(name, description string, variable *int16) *Command
- func (c *Command) Int16sFlag(name, description string, variable *[]int16) *Command
- func (c *Command) Int32Flag(name, description string, variable *int32) *Command
- func (c *Command) Int32sFlag(name, description string, variable *[]int32) *Command
- func (c *Command) Int64Flag(name, description string, variable *int64) *Command
- func (c *Command) Int64sFlag(name, description string, variable *[]int64) *Command
- func (c *Command) Int8Flag(name, description string, variable *int8) *Command
- func (c *Command) Int8sFlag(name, description string, variable *[]int8) *Command
- func (c *Command) IntFlag(name, description string, variable *int) *Command
- func (c *Command) IntsFlag(name, description string, variable *[]int) *Command
- func (c *Command) LongDescription(longdescription string) *Command
- func (c *Command) NewSubCommand(name, description string) *Command
- func (c *Command) NewSubCommandFunction(name string, description string, fn interface{}) *Command
- func (c *Command) NewSubCommandInheritFlags(name, description string) *Command
- func (c *Command) OtherArgs() []string
- func (c *Command) PrintHelp()
- func (c *Command) StringFlag(name, description string, variable *string) *Command
- func (c *Command) StringsFlag(name, description string, variable *[]string) *Command
- func (c *Command) UInt64Flag(name, description string, variable *uint64) *Command
- func (c *Command) Uint16Flag(name, description string, variable *uint16) *Command
- func (c *Command) Uint16sFlag(name, description string, variable *[]uint16) *Command
- func (c *Command) Uint32Flag(name, description string, variable *uint32) *Command
- func (c *Command) Uint32sFlag(name, description string, variable *[]uint32) *Command
- func (c *Command) Uint64sFlag(name, description string, variable *[]uint64) *Command
- func (c *Command) Uint8Flag(name, description string, variable *uint8) *Command
- func (c *Command) Uint8sFlag(name, description string, variable *[]uint8) *Command
- func (c *Command) UintFlag(name, description string, variable *uint) *Command
- func (c *Command) UintsFlag(name, description string, variable *[]uint) *Command
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action func() error
Action represents a function that gets calls when the command is called by the user
type Cli ¶
type Cli struct {
// contains filtered or unexported fields
}
Cli - The main application object.
func (*Cli) AddCommand ¶
AddCommand - Adds a command to the application.
func (*Cli) DefaultCommand ¶
DefaultCommand - Sets the given command as the command to run when no other commands given.
func (*Cli) LongDescription ¶
LongDescription - Sets the long description for the command.
func (*Cli) NewSubCommand ¶
NewSubCommand - Creates a new SubCommand for the application.
func (*Cli) NewSubCommandFunction ¶ added in v1.2.0
func (*Cli) NewSubCommandInheritFlags ¶ added in v1.0.6
NewSubCommandInheritFlags - Creates a new SubCommand for the application, inherit flags from parent Command
func (*Cli) OtherArgs ¶ added in v1.0.3
OtherArgs - Returns the non-flag arguments passed to the cli. NOTE: This should only be called within the context of an action.
func (*Cli) PostRun ¶ added in v1.7.0
PostRun - Calls the given function after running the specific command.
func (*Cli) SetBannerFunction ¶
SetBannerFunction - Set the function that is called to get the banner string.
func (*Cli) SetErrorFunction ¶ added in v1.0.5
SetErrorFunction - Set custom error message when undefined flags are used by the user. First argument is a string containing the commnad path used. Second argument is the undefined flag error.
func (*Cli) ShortDescription ¶
ShortDescription - Get the Application short description.
func (*Cli) StringFlag ¶
StringFlag - Adds a string flag to the root command.
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command represents a command that may be run by the user
func NewCommand ¶
NewCommand creates a new Command func NewCommand(name string, description string, app *Cli, parentCommandPath string) *Command {
func (*Command) AddCommand ¶ added in v0.4.0
AddCommand - Adds a subcommand
func (*Command) Float32Flag ¶ added in v1.7.0
Float32Flag - Adds a float32 flag to the command
func (*Command) Float32sFlag ¶ added in v1.7.0
Float32sFlag - Adds a float32s flag to the command
func (*Command) Float64Flag ¶ added in v1.4.0
Float64Flag - Adds a float64 flag to the command
func (*Command) Float64sFlag ¶ added in v1.7.0
Float64sFlag - Adds a float64s flag to the command
func (*Command) Int16sFlag ¶ added in v1.7.0
Int16sFlag - Adds an int16s flag to the command
func (*Command) Int32sFlag ¶ added in v1.7.0
Int32sFlag - Adds an int32s flag to the command
func (*Command) Int64sFlag ¶ added in v1.7.0
Int64sFlag - Adds an int64s flag to the command
func (*Command) LongDescription ¶
LongDescription - Sets the long description for the command
func (*Command) NewSubCommand ¶
NewSubCommand - Creates a new subcommand
func (*Command) NewSubCommandFunction ¶ added in v1.2.0
func (*Command) NewSubCommandInheritFlags ¶ added in v1.0.6
NewSubCommandInheritFlags - Creates a new subcommand, inherits flags from command
func (*Command) OtherArgs ¶ added in v1.0.4
OtherArgs - Returns the non-flag arguments passed to the subcommand. NOTE: This should only be called within the context of an action.
func (*Command) PrintHelp ¶
func (c *Command) PrintHelp()
PrintHelp - Output the help text for this command
func (*Command) StringFlag ¶
StringFlag - Adds a string flag to the command
func (*Command) StringsFlag ¶ added in v1.7.0
StringsFlag - Adds a strings flag to the command
func (*Command) UInt64Flag ¶ added in v1.4.0
UInt64Flag - Adds an uint64 flag to the command
func (*Command) Uint16Flag ¶ added in v1.7.0
Uint16Flag - Adds an uint16 flag to the command
func (*Command) Uint16sFlag ¶ added in v1.7.0
Uint16sFlag - Adds an uint16s flag to the command
func (*Command) Uint32Flag ¶ added in v1.7.0
Uint32Flag - Adds an uint32 flag to the command
func (*Command) Uint32sFlag ¶ added in v1.7.0
Uint32sFlag - Adds an uint32s flag to the command
func (*Command) Uint64sFlag ¶ added in v1.7.0
Uint64sFlag - Adds an uint64s flag to the command
func (*Command) Uint8sFlag ¶ added in v1.7.0
Uint8sFlag - Adds an uint8 s flag to the command