Documentation
¶
Index ¶
- func Arg(i int) string
- func Args() []string
- func CheckHelpFlag() bool
- func NArg() int
- func Parse() error
- func PrintHelp()
- func SetHelpTitles(firstLine, basicUsage string)
- type Flag
- func (flag *Flag) Bool() *bool
- func (flag *Flag) Byte() *byte
- func (flag *Flag) Custom(val Value)
- func (flag *Flag) Default(defaul string) *Flag
- func (flag *Flag) Float32() *float32
- func (flag *Flag) Float64() *float64
- func (flag *Flag) Int() *int
- func (flag *Flag) Int16() *int16
- func (flag *Flag) Int32() *int32
- func (flag *Flag) Int64() *int64
- func (flag *Flag) Int64Array() *[]int64
- func (flag *Flag) Int8() *int8
- func (flag *Flag) IntArray() *[]int
- func (flag *Flag) Key(short, long string) *Flag
- func (flag *Flag) LongKey(key string) *Flag
- func (flag *Flag) Rune() *rune
- func (flag *Flag) ShortKey(key string) *Flag
- func (flag *Flag) String() *string
- func (flag *Flag) StringArray() *[]string
- func (flag *Flag) StringMap() *map[string]string
- func (flag *Flag) Uint() *uint
- func (flag *Flag) Uint16() *uint16
- func (flag *Flag) Uint32() *uint32
- func (flag *Flag) Uint64() *uint64
- func (flag *Flag) Uint8() *uint8
- func (flag *Flag) Usage(usage string) *Flag
- func (flag *Flag) UsageCategory(category string) *Flag
- func (flag *Flag) ValueName(valname string) *Flag
- type Set
- func (fs *Set) Arg(i int) string
- func (fs *Set) Args() []string
- func (fs *Set) CheckHelpFlag() bool
- func (fs *Set) Make() *Flag
- func (fs *Set) MakeFull(short, long, usage, defVal string) *Flag
- func (fs *Set) MakeHelpFlag() (*bool, *Flag)
- func (fs *Set) MakeKey(short, long string) *Flag
- func (fs *Set) NArg() int
- func (fs *Set) Parse() error
- func (fs *Set) PrintHelp()
- func (fs *Set) SetHelpTitles(firstLine, basicUsage string)
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Arg ¶
Arg returns the string at the given index from the list Args() returns If the index does not exist, Arg will return an empty string.
func CheckHelpFlag ¶
func CheckHelpFlag() bool
CheckHelpFlag checks if the help flag is set and prints the help page if needed. Return value tells whether or not the help page was printed
func SetHelpTitles ¶
func SetHelpTitles(firstLine, basicUsage string)
SetHelpTitles sets the first line (program name and basic explanation) and basic usage specification
Types ¶
type Flag ¶
type Flag struct { Value Value // contains filtered or unexported fields }
Flag represents a single flag
func MakeFull ¶
MakeFull creates and registers a flag with the given short and long keys, usage string and default value
func (*Flag) Byte ¶
Byte sets the type of this flag to a byte (unsigned 8-bit integer) and returns a pointer to the value
func (*Flag) Default ¶
Default sets the default value of this Flag The value given is passed to the Value container of this flag using `Set()`
func (*Flag) Float32 ¶
Float32 sets the type of this flag to an 32-bit float and returns a pointer to the value
func (*Flag) Float64 ¶
Float64 sets the type of this flag to an 64-bit float and returns a pointer to the value
func (*Flag) Int ¶
Int sets the type of this flag to a signed default-length integer and returns a pointer to the value
func (*Flag) Int16 ¶
Int16 sets the type of this flag to a signed 16-bit integer and returns a pointer to the value
func (*Flag) Int32 ¶
Int32 sets the type of this flag to a signed 32-bit integer and returns a pointer to the value
func (*Flag) Int64 ¶
Int64 sets the type of this flag to a signed 64-bit integer and returns a pointer to the value
func (*Flag) Int64Array ¶
Int64Array sets the type of this flag to a signed 64-bit integer array and returns a pointer to the value
func (*Flag) Int8 ¶
Int8 sets the type of this flag to a signed 8-bit integer and returns a pointer to the value
func (*Flag) IntArray ¶
IntArray sets the type of this flag to a signed default-length integer array and returns a pointer to the value
func (*Flag) Rune ¶
Rune sets the type of this flag to a rune (signed 32-bit integer) and returns a pointer to the value
func (*Flag) String ¶
String sets the type of this flag to a string and returns a pointer to the value
func (*Flag) StringArray ¶
StringArray sets the type of this flag to a string array and returns a pointer to the value
func (*Flag) StringMap ¶
StringMap sets the type of this flag to a string-string map and returns a pointer to the value
func (*Flag) Uint ¶
Uint sets the type of this flag to an unsigned default-length integer and returns a pointer to the value
func (*Flag) Uint16 ¶
Uint16 sets the type of this flag to an unsigned 16-bit integer and returns a pointer to the value
func (*Flag) Uint32 ¶
Uint32 sets the type of this flag to an unsigned 32-bit integer and returns a pointer to the value
func (*Flag) Uint64 ¶
Uint64 sets the type of this flag to an unsigned 64-bit integer and returns a pointer to the value
func (*Flag) Uint8 ¶
Uint8 sets the type of this flag to an unsigned 8-bit integer and returns a pointer to the value
func (*Flag) UsageCategory ¶
UsageCategory sets the category of this flag (e.g. Application or Help)
type Set ¶
type Set struct { // The list of strings used as input InputArgs []string // Whether or not to ignore all flags after the user has entered two dashes with no flag key ("--") // If enabled, all arguments after two dashes with no flag key will go into the args array (@see Args()) DoubleLineEscape bool // Whether or not to exit the program when there's an error // If enabled, the error message will be printed to `stderr` after which `os.Exit(1)` will be called. ExitOnError bool // contains filtered or unexported fields }
Set is a set of flags with certain input arguments
func DefaultSet ¶
func DefaultSet() *Set
DefaultSet returns the default flagset which takes its arguments from os.Args
func (*Set) Arg ¶
Arg returns the string at the given index from the list Args() returns If the index does not exist, Arg will return an empty string.
func (*Set) CheckHelpFlag ¶
CheckHelpFlag checks if the help flag is set and prints the help page if needed. Return value tells whether or not the help page was printed
func (*Set) MakeFull ¶
MakeFull creates and registers a flag with the given short and long keys, usage string and default value
func (*Set) MakeHelpFlag ¶
MakeHelpFlag creates the -h, --help flag
func (*Set) Parse ¶
Parse the input arguments in this flagset into mauflag form Before this function is called all the flags will have either the type default or the given default value
func (*Set) SetHelpTitles ¶
SetHelpTitles sets the first line (program name and basic explanation) and basic usage specification
type Value ¶
type Value interface { // Set or add the data in the given string to this value Set(string) error // Name should return the type name of this value or (if this value is an array, // a map or something of that sort) the type name of one object in this value Name() string }
Value represents the value a flag has