Documentation ¶
Index ¶
- Variables
- func Bind(target interface{})
- func BindByArgs(target interface{}, args []string) error
- func Error(info string) error
- func Errorf(format string, obj ...interface{}) error
- func Exit(info interface{})
- func GetIdxInArray(s string) int
- func GetMethod(s reflect.Value, name string) reflect.Value
- func IsImplementDescer(t reflect.Type) bool
- func IsImplementIniter(t reflect.Type) bool
- func IsImplementVerifier(t reflect.Type) bool
- func IsImplemented(t, target reflect.Type) bool
- func IsShowUsage(err error) *showUsageError
- func IsWrapBy(s, ch2 string) bool
- func Register(objs ...Typer)
- func RegisterAll(objs ...BaseTyperParser)
- func Run(target interface{}, context ...interface{})
- func RunByArgs(target interface{}, args []string, context ...interface{}) error
- func SetDesc(target interface{}, desc string)
- func SetToSource(source, val reflect.Value)
- func ShowUsage(hs []*Handler) string
- type BaseTypeArgNamer
- type BaseTypeCanBeValuer
- type BaseTypeNumArgs
- type BaseTyper
- type BaseTyperParser
- type Bool
- type CmdHelp
- type Duration
- type FlaglyDescer
- type FlaglyIniter
- type FlaglySet
- func (f *FlaglySet) Add(h *Handler)
- func (f *FlaglySet) AddSubHandler(command string, hf interface{}) *Handler
- func (f *FlaglySet) Bind(value reflect.Value, args []string) error
- func (f *FlaglySet) Close()
- func (f *FlaglySet) Compile(target interface{}) error
- func (f *FlaglySet) Completer() *HandlerCompleter
- func (f *FlaglySet) Context(obj ...interface{})
- func (f *FlaglySet) GetHandler(name string) *Handler
- func (f *FlaglySet) Lambda(name string, fn func() []string)
- func (f *FlaglySet) Run(args []string) (err error)
- func (f *FlaglySet) SetHandleFunc(hf interface{})
- func (f *FlaglySet) Usage() string
- type FlaglyVerifier
- type Handler
- func (h *Handler) AddHandler(child *Handler)
- func (h *Handler) AddSubHandler(name string, function interface{}) *Handler
- func (h *Handler) Bind(ptr reflect.Value, args []string) (err error)
- func (h *Handler) Call(stack []reflect.Value, args []string) error
- func (h *Handler) Close()
- func (h *Handler) Compile(t reflect.Type) error
- func (h *Handler) CompileIface(obj interface{}) error
- func (h *Handler) Context(obj interface{})
- func (h *Handler) EnsureHelpOption()
- func (h *Handler) GetChildren() []*Handler
- func (h *Handler) GetCommands() []string
- func (h *Handler) GetHandler(name string) *Handler
- func (h *Handler) GetName() string
- func (h *Handler) GetOptionNames() []string
- func (h *Handler) GetRoot() *Handler
- func (h *Handler) GetTreeChildren() []Tree
- func (h *Handler) HasArgOptions() bool
- func (h *Handler) HasDesc() bool
- func (h *Handler) HasFlagOptions() bool
- func (h *Handler) Lambda(name string, fn func() []string)
- func (h *Handler) ResetHandler()
- func (h *Handler) Run(stack *[]reflect.Value, args []string) (err error)
- func (h *Handler) SetGetChildren(f func(*Handler) []*Handler)
- func (h *Handler) SetHandleFunc(obj interface{})
- func (h *Handler) SetOnExit(f func())
- func (h *Handler) SetOptionType(option reflect.Type) error
- func (h *Handler) String() string
- func (h *Handler) Usage(prefix string) string
- func (h *Handler) UsagePrefix() string
- type HandlerCompleter
- type IPNet
- type Int
- type Int64
- type MapStringString
- type Option
- func (o *Option) BindTo(value reflect.Value, args []string) error
- func (o *Option) GetTree(lambdaMap map[string]func() []string) []Tree
- func (o *Option) HasArgName() bool
- func (o *Option) HasDefault() bool
- func (o *Option) HasDesc() bool
- func (o *Option) IsArg() bool
- func (o *Option) IsFlag() bool
- func (o *Option) String() string
- type OptionType
- type SliceWrap
- type String
- type StructTag
- type Tree
- type Typer
- type ValueWrap
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMustAFunc = errors.New("argument must be a func") ErrFuncOutMustAError = errors.New("FlaglyHandle(Context).out must be a error or nothing: %v") ErrMustAPtrToStruct = errors.New("must a pointer to struct") ErrMustAStruct = errors.New("must a struct") )
View Source
var ( EmptyError error EmptyType reflect.Type EmptyValue reflect.Value IfaceError = reflect.TypeOf(&EmptyError).Elem() HandlerType = reflect.TypeOf(new(Handler)) )
View Source
var (
ErrShowUsage error = showUsageError{}
)
View Source
var (
FlaglyIniterName = "FlaglyInit"
)
View Source
var (
NilValue reflect.Value
)
Functions ¶
func BindByArgs ¶
func GetIdxInArray ¶
func IsImplementDescer ¶
func IsImplementIniter ¶
func IsImplementVerifier ¶
func IsImplemented ¶
func IsShowUsage ¶
func IsShowUsage(err error) *showUsageError
func RegisterAll ¶
func RegisterAll(objs ...BaseTyperParser)
func SetToSource ¶
Types ¶
type BaseTypeArgNamer ¶
type BaseTypeArgNamer interface {
ArgName() string
}
type BaseTypeCanBeValuer ¶
type BaseTypeNumArgs ¶
type BaseTyperParser ¶
type FlaglyDescer ¶
type FlaglyDescer interface {
FlaglyDesc() string
}
type FlaglyIniter ¶
type FlaglyIniter interface {
FlaglyInit()
}
type FlaglySet ¶
type FlaglySet struct {
// contains filtered or unexported fields
}
func (*FlaglySet) AddSubHandler ¶
func (*FlaglySet) Completer ¶
func (f *FlaglySet) Completer() *HandlerCompleter
func (*FlaglySet) GetHandler ¶
func (*FlaglySet) SetHandleFunc ¶
func (f *FlaglySet) SetHandleFunc(hf interface{})
type FlaglyVerifier ¶
type FlaglyVerifier interface {
FlaglyVerify() error
}
type Handler ¶
type Handler struct { Parent *Handler Name string Desc string Children []*Handler Options []*Option OptionType reflect.Type // contains filtered or unexported fields }
func NewHandler ¶
func NewHandlerHelp ¶
func NewHandlerHelp() *Handler
func (*Handler) AddHandler ¶
func (*Handler) AddSubHandler ¶
combine NewHander(name).SetHanderFunc()/AddHandler(subHandler)
func (*Handler) CompileIface ¶
func (*Handler) EnsureHelpOption ¶
func (h *Handler) EnsureHelpOption()
func (*Handler) GetChildren ¶
func (*Handler) GetCommands ¶
func (*Handler) GetHandler ¶
func (*Handler) GetOptionNames ¶
func (*Handler) GetTreeChildren ¶
func (*Handler) HasArgOptions ¶
func (*Handler) HasFlagOptions ¶
func (*Handler) ResetHandler ¶
func (h *Handler) ResetHandler()
func (*Handler) SetGetChildren ¶
func (*Handler) SetHandleFunc ¶
func (h *Handler) SetHandleFunc(obj interface{})
only func is accepted 1. func() error 2. func(*struct) error 3. func(*struct, *flagly.Handler) error 4. func(*flagly.Handler) error 5. func(Handler, Context) error
func (*Handler) UsagePrefix ¶
type HandlerCompleter ¶
type HandlerCompleter struct {
// contains filtered or unexported fields
}
type MapStringString ¶
type MapStringString struct{}
func (MapStringString) ArgName ¶
func (MapStringString) ArgName() string
func (MapStringString) CanBeValue ¶
func (MapStringString) CanBeValue(string) bool
func (MapStringString) NumArgs ¶
func (MapStringString) NumArgs() (int, int)
func (MapStringString) Type ¶
func (MapStringString) Type() reflect.Type
type Option ¶
type Option struct { Index int Name string LongName string Type OptionType BindType reflect.Type Typer Typer Desc string Default *string ArgName *string ArgIdx int ShowUsage bool Tag StructTag }
func NewHelpFlag ¶
func NewHelpFlag() *Option
func ParseStructToOptions ¶
func (*Option) HasArgName ¶
func (*Option) HasDefault ¶
type OptionType ¶
type OptionType int
const ( FlagOption OptionType = iota ArgOption )
func (OptionType) String ¶
func (t OptionType) String() string
type Tree ¶
func StringTree ¶
type Typer ¶
type Typer interface { BaseTyper BaseTypeNumArgs BaseTypeCanBeValuer Set(source reflect.Value, args []string) error }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
demo
|
|
flagly-shell
usage: $ go install github.com/chzyer/flagly/demo/flagly-shell $ flagly-shell > help commands: help time base64 > time 2016-02-11 12:12:43 > time -h usage: time [option] [--] [<layout>] options: -h show help > base64 missing content usage: base64 [option] [--] <content> options: -d decode string -h show help > base64 hello aGVsbG8=
|
usage: $ go install github.com/chzyer/flagly/demo/flagly-shell $ flagly-shell > help commands: help time base64 > time 2016-02-11 12:12:43 > time -h usage: time [option] [--] [<layout>] options: -h show help > base64 missing content usage: base64 [option] [--] <content> options: -d decode string -h show help > base64 hello aGVsbG8= |
Click to show internal directories.
Click to hide internal directories.