Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgsParser ¶
type ArgsParser struct {
// BoolOpts bool option names. list all bool value options.
// eg. "--debug -h" -> []string{"debug", "h"}
BoolOpts []string
// ArrayOpts array option names. list all array value options.
// eg. "--name tom --name john" should add []string{"name"}
ArrayOpts []string
// contains filtered or unexported fields
}
ArgsParser definition. a simple command line args parser
func ParseArgs ¶
func ParseArgs(args []string, boolOpts []string, arrayOpts []string) *ArgsParser
ParseArgs parse os.Args to options.
func (*ArgsParser) Parse ¶
func (p *ArgsParser) Parse(args []string)
Parse args list to options
Supports options format:
-e // bool, short option -e <value> // short option -e=<value> -aux // multi short bool options --bool-opt // bool, lang option --long-opt <value> // lang option --long-opt=<value>
type Option ¶
type Option struct {
Name string
Short string
// Type value type. allow: int, string, bool, ints, strings, bools
Type string
// Value of the option. allow: bool, string, array
Value interface{}
Required bool
DefValue interface{}
// Description
Description string
}
Option is config info for a option usage:
cmd.AddOpt(Option{
Name: "name"
Short: "n"
DType: "string"
})
cmd.Flags.String()
Click to show internal directories.
Click to hide internal directories.