Documentation
¶
Overview ¶
Package sflag is an simple cli flag parse tool
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 NewArgsParser ¶
func NewArgsParser(boolOpts []string, arrayOpts []string) *ArgsParser
NewArgsParser create
func ParseArgs ¶
func ParseArgs(args []string, boolOpts []string, arrayOpts []string) *ArgsParser
ParseArgs parse os.Args to options.
func (*ArgsParser) OptsString ¶
func (p *ArgsParser) OptsString() string
OptsString convert all options to string
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 ValueGetter ¶
type ValueGetter struct { // value store parsed argument data. (type: string, []string) Value any // is array Arrayed bool }
ValueGetter struct
func (*ValueGetter) Array ¶
func (v *ValueGetter) Array() (ss []string)
Array alias of the Strings()
func (*ValueGetter) String ¶
func (v *ValueGetter) String(defVal ...string) string
String argument value to string
func (*ValueGetter) Strings ¶
func (v *ValueGetter) Strings() (ss []string)
Strings value to string slice, if argument isArray = true.
Click to show internal directories.
Click to hide internal directories.