Documentation ¶
Index ¶
- func AddCommand(path string, cmd func(), brief string)
- func AddConfig(path string, unmarshaler Unmarshaler)
- func AddRootCommand(cmd func())
- func Alias(name, definition string)
- func Args() []string
- func Description(text string)
- func Launch(args ...string)
- func Parse(v interface{}, opts ...ParseOption)
- func Title(text string)
- func Usage()
- func UsageString() string
- func Use(opts ...Option)
- type Command
- type Cortana
- func (c *Cortana) AddCommand(path string, cmd func(), brief string)
- func (c *Cortana) AddConfig(path string, unmarshaler Unmarshaler)
- func (c *Cortana) AddEnvUnmarshaler(unmarshaler EnvUnmarshaler)
- func (c *Cortana) AddRootCommand(cmd func())
- func (c *Cortana) Alias(name, definition string)
- func (c *Cortana) Args() []string
- func (c *Cortana) Commands() []*Command
- func (c *Cortana) Complete(prefix string) []*Command
- func (c *Cortana) Description(text string)
- func (c *Cortana) Launch(args ...string)
- func (c *Cortana) Parse(v interface{}, opts ...ParseOption)
- func (c *Cortana) SearchCommand(args []string) *Command
- func (c *Cortana) Title(text string)
- func (c *Cortana) Usage()
- func (c *Cortana) UsageString() string
- func (c *Cortana) Use(opts ...Option)
- type EnvUnmarshalFunc
- type EnvUnmarshaler
- type Option
- type ParseOption
- type UnmarshalFunc
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddConfig ¶
func AddConfig(path string, unmarshaler Unmarshaler)
AddConfig adds a configuration file
func AddRootCommand ¶
func AddRootCommand(cmd func())
AddRootCommand adds the command without sub path
func Alias ¶
func Alias(name, definition string)
Alias gives another name for command. Ex. cortana.Alias("rmi", "rm -i")
func Description ¶
func Description(text string)
Description set the description for the command, it always be helpful to describe about the details of command
Types ¶
type Command ¶
type Command struct { Path string Proc func() Brief string Alias bool // contains filtered or unexported fields }
Command is an executive unit
func SearchCommand ¶
SearchCommand returns the command according the args
type Cortana ¶
type Cortana struct {
// contains filtered or unexported fields
}
Cortana is the commander
func (*Cortana) AddCommand ¶
AddCommand adds a command
func (*Cortana) AddConfig ¶
func (c *Cortana) AddConfig(path string, unmarshaler Unmarshaler)
AddConfig adds a config file
func (*Cortana) AddEnvUnmarshaler ¶
func (c *Cortana) AddEnvUnmarshaler(unmarshaler EnvUnmarshaler)
func (*Cortana) AddRootCommand ¶
func (c *Cortana) AddRootCommand(cmd func())
AddRootCommand adds the command without sub path
func (*Cortana) Description ¶
Description set the description for the command, it always be helpful to describe about the details of command
func (*Cortana) SearchCommand ¶
SearchCommand returns the command according the args
type EnvUnmarshalFunc ¶
type EnvUnmarshalFunc func(v interface{}) error
EnvUnmarshalFunc turns a func to an EnvUnmarshaler
func (EnvUnmarshalFunc) Unmarshal ¶
func (f EnvUnmarshalFunc) Unmarshal(v interface{}) error
Unmarshal the environment variables
type EnvUnmarshaler ¶
type EnvUnmarshaler interface {
Unmarshal(v interface{}) error
}
EnvUnmarshaler unmarshals the environment variables
type Option ¶
type Option func(c *Cortana)
func ConfFlag ¶
func ConfFlag(long, short string, unmarshaler Unmarshaler) Option
ConfFlag parse the configration file path from flags
func DisableHelpFlag ¶
func DisableHelpFlag() Option
func ExitOnError ¶
func WithStderr ¶
func WithStdout ¶
type ParseOption ¶
type ParseOption func(opt *parseOption)
func IgnoreUnknownArgs ¶
func IgnoreUnknownArgs() ParseOption
func OnUsage ¶
func OnUsage(f func(usage string)) ParseOption
func WithArgs ¶
func WithArgs(args []string) ParseOption
type UnmarshalFunc ¶
UnmarshalFunc turns a func to Unmarshaler
func (UnmarshalFunc) Unmarshal ¶
func (f UnmarshalFunc) Unmarshal(data []byte, v interface{}) error
Unmarshal the data
type Unmarshaler ¶
Unmarshaler unmarshals data to v