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) 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) Float64Flag(name, description string, variable *float64) *Command
- func (c *Command) Hidden()
- func (c *Command) Int64Flag(name, description string, variable *int64) *Command
- func (c *Command) IntFlag(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) UInt64Flag(name, description string, variable *uint64) *Command
- func (c *Command) UintFlag(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) 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) Float64Flag ¶ added in v1.4.0
Float64Flag - Adds a float64 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) UInt64Flag ¶ added in v1.4.0
UInt64Flag - Adds an int flag to the command