Documentation
¶
Index ¶
- Variables
- func ContainArgument(str string) (ok bool)
- func ContainCommand(str string) (ok bool)
- func ContainOption(str string) (ok bool)
- func RegexpArgument(str string) []string
- func RegexpCommand(str string) []string
- func RegexpOption(str string) []string
- type Action
- type Action1
- type Action2
- type Action3
- type Argument
- type Arguments
- type Command
- func (c *Command) Action(action interface{}, keys ...[]string) Commander
- func (c *Command) Annotation(title string, contents []string) Commander
- func (c *Command) Command(usage string, args ...interface{}) Commander
- func (c *Command) Description(desc string) Commander
- func (c Command) GetHelpMessage() string
- func (c *Command) Line(usage string, args ...interface{}) *Command
- func (c *Command) LineArgument(usage string, args ...interface{}) Commander
- func (c *Command) LineOption(usage string, args ...interface{}) Commander
- func (c Command) Name() string
- func (c Command) Names() []string
- func (c *Command) Option(usage string, args ...interface{}) Commander
- func (c Command) OptionsString() (r []string)
- func (c Command) Parse(args ...[]string) (*Context, error)
- func (c Command) ShowHelpMessage() string
- func (c *Command) Usage(usage string, args ...interface{}) Commander
- func (c Command) UsagesString() (r []string)
- func (c Command) Valid() bool
- func (c *Command) Version(ver string) Commander
- type Commander
- type Commands
- type Context
- type ContextArgs
- type DocoptMap
- func (d DocoptMap) Contain(key string) bool
- func (d DocoptMap) Get(key string) interface{}
- func (d DocoptMap) GetBool(key string) (bool, bool)
- func (d DocoptMap) GetFloat(key string) (float32, bool)
- func (d DocoptMap) GetFloat64(key string) (float64, bool)
- func (d DocoptMap) GetInt(key string) (int, bool)
- func (d DocoptMap) GetInt64(key string) (int64, bool)
- func (d DocoptMap) GetMustBool(key string) bool
- func (d DocoptMap) GetString(key string) string
- func (d DocoptMap) GetStrings(key string) []string
- func (d DocoptMap) Map() map[string]interface{}
- func (d DocoptMap) String() string
- type ErrFunc
- type Option
- type Options
- type Result
- type ResultCode
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ContainArgument ¶
ContainArgument str contain docopt argument format
func ContainCommand ¶
ContainCommand str contain docopt command format
func ContainOption ¶
ContainOption str contain docopt option format
func RegexpArgument ¶
RegexpArgument Regular screening out docopt arguments
func RegexpCommand ¶
RegexpCommand Regular screening out docopt commands
func RegexpOption ¶
RegexpOption Regular screening out docopt options
Types ¶
type Argument ¶
type Argument struct {
// contains filtered or unexported fields
}
Argument Implementation of command line parameter
func (Argument) OptionString ¶
func (Argument) UsageString ¶
type Arguments ¶
type Arguments []*Argument
Arguments Implementation of command line parameters
func (Arguments) OptionsString ¶
func (Arguments) UsagesString ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command Command line command implementation
func (*Command) Annotation ¶
func (*Command) Description ¶
func (Command) GetHelpMessage ¶
func (*Command) LineArgument ¶
func (*Command) LineOption ¶
func (Command) OptionsString ¶
func (Command) ShowHelpMessage ¶
func (Command) UsagesString ¶
type Commander ¶
type Commander interface { Version(ver string) Commander Description(desc string) Commander Annotation(title string, contents []string) Commander Action(action interface{}, keys ...[]string) Commander Command(usage string, args ...interface{}) Commander Option(usage string, args ...interface{}) Commander LineArgument(usage string, args ...interface{}) Commander LineOption(usage string, args ...interface{}) Commander UsagesString() []string OptionsString() []string GetHelpMessage() string ShowHelpMessage() string Parse(argv ...[]string) (*Context, error) }
Commander Command line implementation
var Program Commander = newCommander()
type Commands ¶
type Commands []*Command
Commands Command line commands implementation
func (Commands) OptionsString ¶
type Context ¶
type Context struct { Args ContextArgs `json:"arguments"` Doc DocoptMap `json:"docopt"` }
Context
type ContextArgs ¶
type ContextArgs []string
func (ContextArgs) Get ¶
func (c ContextArgs) Get(index int) string
func (ContextArgs) String ¶
func (c ContextArgs) String() string
func (ContextArgs) StringSeparator ¶ added in v0.6.0
func (c ContextArgs) StringSeparator(sep string, offsets ...int) string
type DocoptMap ¶
type DocoptMap map[string]interface{}
DocoptMap docopt returns a map of option names to the values
func (DocoptMap) GetMustBool ¶
func (DocoptMap) GetStrings ¶
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option
func (*Option) Action ¶
func (a *Option) Action(action interface{}, keys ...[]string)
Action set executive function to actor.action and actor.musts action like: func(c *Context) Result
func(c *Context) error func(c *Context) func(m map[string]interface{}) error
func (Option) IsOptional ¶
func (Option) IsRequired ¶
func (Option) OptionString ¶
func (Option) UsageString ¶
type Result ¶
var ( ResultPass Result = &ResultCode{} ResultBreak = &ResultCode{_break: true} )
func NewResultCode ¶
func NewResultError ¶
type ResultCode ¶
type ResultCode struct {
// contains filtered or unexported fields
}
func (ResultCode) Break ¶
func (e ResultCode) Break() bool
func (ResultCode) Code ¶
func (e ResultCode) Code() int
func (ResultCode) Error ¶
func (e ResultCode) Error() error
func (ResultCode) ErrorString ¶
func (e ResultCode) ErrorString() string
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
calculator_example
command
|
|
counted_example
command
|
|
naval_fate
command
|
|
quick_example
command
|
|