Documentation ¶
Index ¶
- Variables
- type CLI
- func (cmd *CLI) AddSubCommand(subcmd *SubCommand) *SubCommand
- func (cmd *CLI) AddSubCommands(subcmds ...*SubCommand)
- func (cmd *CLI) AliasFlag(alias rune, flagname string)
- func (cmd *CLI) AliasName(alias, subCommand string)
- func (cmd *CLI) Arg(index int) values.Value
- func (cmd *CLI) Args() values.List
- func (cmd *CLI) CommandUsageString() string
- func (cmd *CLI) DefaultUsage()
- func (cmd *CLI) DefineBoolFlag(name string, value bool, usage string) *bool
- func (cmd *CLI) DefineBoolFlagVar(p *bool, name string, value bool, usage string)
- func (cmd *CLI) DefineDurationFlag(name string, value time.Duration, usage string) *time.Duration
- func (cmd *CLI) DefineDurationFlagVar(p *time.Duration, name string, value time.Duration, usage string)
- func (cmd *CLI) DefineFlag(value values.Value, name string, usage string)
- func (cmd *CLI) DefineFloat64Flag(name string, value float64, usage string) *float64
- func (cmd *CLI) DefineFloat64FlagVar(p *float64, name string, value float64, usage string)
- func (cmd *CLI) DefineInt64Flag(name string, value int64, usage string) *int64
- func (cmd *CLI) DefineInt64FlagVar(p *int64, name string, value int64, usage string)
- func (cmd *CLI) DefineIntFlag(name string, value int, usage string) *int
- func (cmd *CLI) DefineIntFlagVar(p *int, name string, value int, usage string)
- func (cmd *CLI) DefineParams(names ...string)
- func (cmd *CLI) DefineStringFlag(name string, value string, usage string) *string
- func (cmd *CLI) DefineStringFlagVar(p *string, name string, value string, usage string)
- func (cmd *CLI) DefineSubCommand(name string, desc string, fn func(Command), paramNames ...string) *SubCommand
- func (cmd *CLI) DefineUint64Flag(name string, value uint64, usage string) *uint64
- func (cmd *CLI) DefineUint64FlagVar(p *uint64, name string, value uint64, usage string)
- func (cmd *CLI) DefineUintFlag(name string, value uint, usage string) *uint
- func (cmd *CLI) DefineUintFlagVar(p *uint, name string, value uint, usage string)
- func (cmd *CLI) Description() string
- func (cmd *CLI) ErrOutput() io.Writer
- func (cmd *CLI) ErrPrint(a ...interface{})
- func (cmd *CLI) ErrPrintf(format string, a ...interface{})
- func (cmd *CLI) ErrPrintln(a ...interface{})
- func (cmd *CLI) Flag(name string) values.Value
- func (cmd *CLI) Flags() values.Map
- func (cmd *CLI) FlagsUsageString(title string) string
- func (cmd *CLI) InheritFlag(name string)
- func (cmd *CLI) InheritFlags(names ...string)
- func (cmd *CLI) LongDescription() string
- func (cmd *CLI) Mute()
- func (cmd *CLI) Name() string
- func (cmd *CLI) NameAliases() map[string]string
- func (cmd *CLI) Param(name string) values.Value
- func (cmd *CLI) Params() values.Map
- func (cmd *CLI) ParamsUsageString() string
- func (cmd *CLI) Parent() Command
- func (cmd *CLI) Print(a ...interface{})
- func (cmd *CLI) Printf(format string, a ...interface{})
- func (cmd *CLI) Println(a ...interface{})
- func (cmd *CLI) SetErrOutput(writer io.Writer)
- func (cmd *CLI) SetLongDescription(desc string)
- func (cmd *CLI) SetStdErr(writer io.Writer)
- func (cmd *CLI) SetStdOut(writer io.Writer)
- func (cmd *CLI) SetStdOutput(writer io.Writer)
- func (cmd *CLI) Start(args ...string)
- func (cmd *CLI) StdErr() io.Writer
- func (cmd *CLI) StdOut() io.Writer
- func (cmd *CLI) StdOutput() io.Writer
- func (cmd *CLI) SubCommandsInheritFlag(name string)
- func (cmd *CLI) SubCommandsInheritFlags(names ...string)
- func (cmd *CLI) SubCommandsUsageString(title string) string
- func (cmd *CLI) Usage()
- func (cmd *CLI) UsageString() string
- func (cmd *CLI) Version() string
- type Command
- type ErrorHandling
- type Flag
- type Param
- type ShellTable
- type ShellTableColumn
- type ShellTableRow
- type SubCommand
Constants ¶
This section is empty.
Variables ¶
var NewCLI = New
Alias for New
var ShowUsage = func(cmd Command) { cmd.Usage() }
ShowUsage is a function to show usage
Functions ¶
This section is empty.
Types ¶
type CLI ¶
type CLI struct { ErrorHandling ErrorHandling // contains filtered or unexported fields }
CLI represents a set of defined flags. The zero value of a FlagSet has no name and has ContinueOnError error handling.
func New ¶ added in v1.1.0
New returns a new cli with the specified name and error handling property.
func (*CLI) AddSubCommand ¶ added in v1.3.0
func (cmd *CLI) AddSubCommand(subcmd *SubCommand) *SubCommand
AddSubCommand adds a subcommand to a command
func (*CLI) AddSubCommands ¶ added in v1.3.0
func (cmd *CLI) AddSubCommands(subcmds ...*SubCommand)
AddSubCommands adds subcommands to a command
func (*CLI) CommandUsageString ¶ added in v1.6.0
CommandUsageString returns the command and its accepted options and params
func (*CLI) DefaultUsage ¶ added in v1.3.0
func (cmd *CLI) DefaultUsage()
DefaultUsage is the Default Usage used by odin
func (*CLI) DefineBoolFlag ¶
DefineBoolFlag defines a bool flag with specified name, default value, and usage string. The return value is the address of a bool variable that stores the value of the flag.
func (*CLI) DefineBoolFlagVar ¶
DefineBoolFlagVar defines a bool flag with specified name, default value, and usage string. The argument p points to a bool variable in which to store the value of the flag.
func (*CLI) DefineDurationFlag ¶
DefineDurationFlag defines a time.Duration flag with specified name, default value, and usage string. The return value is the address of a time.Duration variable that stores the value of the flag.
func (*CLI) DefineDurationFlagVar ¶
func (cmd *CLI) DefineDurationFlagVar(p *time.Duration, name string, value time.Duration, usage string)
DefineDurationFlagVar defines a time.Duration flag with specified name, default value, and usage string. The argument p points to a time.Duration variable in which to store the value of the flag.
func (*CLI) DefineFlag ¶
DefineFlag defines a flag with the specified name and usage string. The type and value of the flag are represented by the first argument, of type Value, which typically holds a user-defined implementation of Value. For instance, the caller could create a flag that turns a comma-separated string into a slice of strings by giving the slice the methods of Value; in particular, Set would decompose the comma-separated string into the slice.
func (*CLI) DefineFloat64Flag ¶
DefineFloat64Flag defines a float64 flag with specified name, default value, and usage string. The return value is the address of a float64 variable that stores the value of the flag.
func (*CLI) DefineFloat64FlagVar ¶
DefineFloat64FlagVar defines a float64 flag with specified name, default value, and usage string. The argument p points to a float64 variable in which to store the value of the flag.
func (*CLI) DefineInt64Flag ¶
DefineInt64Flag defines an int64 flag with specified name, default value, and usage string. The return value is the address of an int64 variable that stores the value of the flag.
func (*CLI) DefineInt64FlagVar ¶
DefineInt64FlagVar defines an int64 flag with specified name, default value, and usage string. The argument p points to an int64 variable in which to store the value of the flag.
func (*CLI) DefineIntFlag ¶
DefineIntFlag defines an int flag with specified name, default value, and usage string. The return value is the address of an int variable that stores the value of the flag.
func (*CLI) DefineIntFlagVar ¶
DefineIntFlagVar defines an int flag with specified name, default value, and usage string. The argument p points to an int variable in which to store the value of the flag.
func (*CLI) DefineParams ¶ added in v1.0.0
DefineParams sets params names from strings
func (*CLI) DefineStringFlag ¶
DefineStringFlag defines a string flag with specified name, default value, and usage string. The return value is the address of a string variable that stores the value of the flag.
func (*CLI) DefineStringFlagVar ¶
DefineStringFlagVar defines a string flag with specified name, default value, and usage string. The argument p points to a string variable in which to store the value of the flag.
func (*CLI) DefineSubCommand ¶
func (cmd *CLI) DefineSubCommand(name string, desc string, fn func(Command), paramNames ...string) *SubCommand
DefineSubCommand defines and adds a SubCommand on the current command
func (*CLI) DefineUint64Flag ¶
DefineUint64Flag defines a uint64 flag with specified name, default value, and usage string. The return value is the address of a uint64 variable that stores the value of the flag.
func (*CLI) DefineUint64FlagVar ¶
DefineUint64FlagVar defines a uint64 flag with specified name, default value, and usage string. The argument p points to a uint64 variable in which to store the value of the flag.
func (*CLI) DefineUintFlag ¶
DefineUintFlag defines a uint flag with specified name, default value, and usage string. The return value is the address of a uint variable that stores the value of the flag.
func (*CLI) DefineUintFlagVar ¶
DefineUintFlagVar defines a uint flag with specified name, default value, and usage string. The argument p points to a uint variable in which to store the value of the flag.
func (*CLI) Description ¶
Description returns the command description
func (*CLI) ErrPrint ¶ added in v1.7.0
func (cmd *CLI) ErrPrint(a ...interface{})
ErrPrint does a fmt.Print to the std err of the CLI
func (*CLI) ErrPrintln ¶ added in v1.7.0
func (cmd *CLI) ErrPrintln(a ...interface{})
ErrPrintln does a fmt.Println to the std err of the CLI
func (*CLI) Flag ¶
Flag returns the Value interface to the value of the named flag, returning nil if none exists.
func (*CLI) FlagsUsageString ¶ added in v1.3.0
FlagsUsageString returns the flags usage as a string
func (*CLI) InheritFlag ¶ added in v1.4.0
InheritFlag allows a flags value to inherit from the commands parent
func (*CLI) InheritFlags ¶ added in v1.4.0
InheritFlags allow flag values inherit from the commands parent
func (*CLI) LongDescription ¶ added in v1.6.0
LongDescription is the long description for a command.
func (*CLI) NameAliases ¶ added in v1.8.0
NameAliases sets the name aliases
func (*CLI) ParamsUsageString ¶ added in v1.3.0
ParamsUsageString returns the params usage as a string
func (*CLI) Print ¶ added in v1.7.0
func (cmd *CLI) Print(a ...interface{})
Print does a fmt.Print to the std out of the CLI
func (*CLI) Println ¶ added in v1.7.0
func (cmd *CLI) Println(a ...interface{})
Println does a fmt.Println to the std out of the CLI
func (*CLI) SetErrOutput ¶ added in v1.3.1
SetErrOutput is an alias for SetStdErr
func (*CLI) SetLongDescription ¶ added in v1.6.0
SetLongDescription sets the long desription. This will will replace the description when viewing the --help for a command.
func (*CLI) SetStdOutput ¶ added in v1.3.1
SetStdOutput is an alias for SetStdOut
func (*CLI) SubCommandsInheritFlag ¶ added in v1.4.0
SubCommandsInheritFlag tells all subcommands to inherit a flag
func (*CLI) SubCommandsInheritFlags ¶ added in v1.4.0
SubCommandsInheritFlags tells all subcommands to inherit flags
func (*CLI) SubCommandsUsageString ¶ added in v1.3.0
SubCommandsUsageString is the usage string for sub commands
func (*CLI) UsageString ¶
UsageString returns the command usage as a string
type Command ¶
type Command interface { // Freeform Arguments Arg(int) values.Value Args() values.List // Attributes Name() string NameAliases() map[string]string Description() string Version() string // Flags Flag(string) values.Value Flags() values.Map // Params Param(string) values.Value Params() values.Map // Outputs ErrPrint(...interface{}) ErrPrintf(string, ...interface{}) ErrPrintln(...interface{}) Print(...interface{}) Printf(string, ...interface{}) Println(...interface{}) StdOut() io.Writer StdErr() io.Writer // Misc Parent() Command Usage() }
Command represents a readable command
type ErrorHandling ¶
type ErrorHandling int
ErrorHandling defines how to handle flag parsing errors.
const ( ContinueOnError ErrorHandling = iota ExitOnError PanicOnError )
type Flag ¶
type Flag struct { Name string // name as it appears on command line Usage string // help message DefValue string // default value (as text); for usage message // contains filtered or unexported fields }
A Flag represents the state of a flag.
type Param ¶
type Param struct { Name string // name as it appears on command line Value values.Value // value as set DefValue string // default value (as text); for usage message }
A Param represents the state of a flag.
type ShellTable ¶ added in v1.6.1
type ShellTable struct {
// contains filtered or unexported fields
}
ShellTable is a table to be rendered in the shell.
func NewSharedShellTable ¶ added in v1.6.1
func NewSharedShellTable(sep *string, widPtr *[]int) *ShellTable
NewSharedShellTable initialized and returns a new ShellTable with shared ptrs
func NewShellTable ¶ added in v1.6.1
func NewShellTable(sep string) *ShellTable
NewShellTable initialized and returns a new ShellTable
func (*ShellTable) MaxColumnWidths ¶ added in v1.6.1
func (t *ShellTable) MaxColumnWidths() []int
MaxColumnWidths returns an array of max column widths for each column
func (*ShellTable) Row ¶ added in v1.6.1
func (t *ShellTable) Row() *ShellTableRow
Row adds a new row to the shell table
func (*ShellTable) String ¶ added in v1.6.1
func (t *ShellTable) String() string
type ShellTableColumn ¶ added in v1.6.1
ShellTableColumn is a buffer for a column
type ShellTableRow ¶ added in v1.6.1
type ShellTableRow struct {
// contains filtered or unexported fields
}
ShellTableRow is a row
func (*ShellTableRow) Column ¶ added in v1.6.1
func (r *ShellTableRow) Column(strs ...string) *ShellTableColumn
Column creates a new column
type SubCommand ¶
type SubCommand struct {
CLI
}
SubCommand is a subcommand to a cli
func NewSubCommand ¶ added in v1.3.0
func NewSubCommand(name string, desc string, fn func(Command), paramNames ...string) *SubCommand
NewSubCommand Create a new subcommand instance
Source Files ¶
- CLI.go
- Command.go
- ErrorHandling.go
- Flag.go
- FlagMap.go
- Param.go
- ParamsList.go
- SubCommand.go
- aliasName.go
- attributes.go
- doc.go
- errors.go
- flag_access.go
- flag_definitions.go
- flag_inheritance.go
- flag_parsing.go
- freeform_args_access.go
- freeform_args_parsing.go
- output.go
- param_access.go
- param_definitions.go
- param_parsing.go
- shellTable.go
- subCommandList.go
- subCommand_definitions.go
- subCommand_parsing.go
- usage.go