Documentation
¶
Overview ¶
Package options provides methods for working with command-line options
Index ¶
- Constants
- func Add(name string, opt *V) error
- func AddMap(optMap Map) []error
- func GetB(name string) bool
- func GetF(name string) float64
- func GetI(name string) int
- func GetS(name string) string
- func Has(name string) bool
- func ParseOptionName(name string) (string, string)
- func Q(opts ...string) string
- type Arguments
- type Map
- type OptionError
- type Options
- func (opts *Options) Add(name string, option *V) error
- func (opts *Options) AddMap(optMap Map) []error
- func (opts *Options) GetB(name string) bool
- func (opts *Options) GetF(name string) float64
- func (opts *Options) GetI(name string) int
- func (opts *Options) GetS(name string) string
- func (opts *Options) Has(name string) bool
- func (opts *Options) Parse(rawOpts []string, optMap ...Map) (Arguments, []error)
- type V
Constants ¶
View Source
const ( STRING = iota // String option INT // Int/Uint option BOOL // Boolean option FLOAT // Floating number option MIXED // String or boolean option )
Options types
View Source
const ( ERROR_UNSUPPORTED = iota ERROR_NO_NAME ERROR_DUPLICATE_LONGNAME ERROR_DUPLICATE_SHORTNAME ERROR_OPTION_IS_NIL ERROR_EMPTY_VALUE ERROR_REQUIRED_NOT_SET ERROR_WRONG_FORMAT ERROR_CONFLICT ERROR_BOUND_NOT_SET ERROR_UNSUPPORTED_VALUE )
Error codes
Variables ¶
This section is empty.
Functions ¶
func ParseOptionName ¶
ParseOptionName parses combined name and returns long and short options
Types ¶
type Arguments ¶
type Arguments []string
type OptionError ¶
OptionError is argument parsing error
func (OptionError) Error ¶
func (e OptionError) Error() string
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options is options struct
type V ¶
type V struct { Type int // option type Max float64 // maximum integer option value Min float64 // minimum integer option value Alias string // list of aliases Conflicts string // list of conflicts options Bound string // list of bound options Mergeble bool // option supports options value merging Required bool // option is required Value interface{} // default value // contains filtered or unexported fields }
V is basic option struct
Click to show internal directories.
Click to hide internal directories.