Documentation ¶
Index ¶
- Variables
- func BoolValue(option *Option) (bool, error)
- func Float32Value(option *Option) (float32, error)
- func Float64Value(option *Option) (float64, error)
- func Int64Value(option *Option) (int64, error)
- func IntValue(option *Option) (int, error)
- func StringValue(option *Option) (string, error)
- func Uint64Value(option *Option) (uint64, error)
- func UintValue(option *Option) (uint, error)
- type Bool
- type Command
- type Flags
- func (flags *Flags) GetCalledCommand() *Command
- func (flags *Flags) Init(appName string, appDescription string)
- func (flags *Flags) Parse(printHelpOnError bool) error
- func (flags *Flags) ParseArgs(args []string, printHelpOnError bool) error
- func (flags *Flags) PrintHelp()
- func (flags *Flags) PrintHelpWithArgs(args []string, output io.Writer)
- func (flags *Flags) WithCommands(cmds ...*Command)
- func (flags *Flags) WithOptions(opts ...*Option)
- type Float32
- type Float64
- type Int
- type Int64
- type Option
- func NewBool(long string, short rune, description string, defaultValue bool) *Option
- func NewFloat32(long string, short rune, description string, defaultValue float32) *Option
- func NewFloat64(long string, short rune, description string, defaultValue float64) *Option
- func NewInt(long string, short rune, description string, defaultValue int) *Option
- func NewInt64(long string, short rune, description string, defaultValue int64) *Option
- func NewString(long string, short rune, description string, defaultValue string) *Option
- func NewUint(long string, short rune, description string, defaultValue uint) *Option
- func NewUint64(long string, short rune, description string, defaultValue uint64) *Option
- type String
- type Uint
- type Uint64
- type Value
Constants ¶
This section is empty.
Variables ¶
var EmptyShort rune
EmptyShort the short option name's null-value
var HelpOption = &Option{ Short: 'h', Long: "help", Description: "Show the application's help", Value: &Bool{}, }
HelpOption add it to the root to enable the automatic help prompt
Functions ¶
func Float32Value ¶
Float32Value return the value of a Float32 option
func Float64Value ¶
Float64Value return the value of a Float64 option
func Int64Value ¶
Int64Value return the value of an Int option
func StringValue ¶
StringValue return the value of a String option
func Uint64Value ¶
Uint64Value return the value of a Float64 option
Types ¶
type Bool ¶
Bool bool option value (and default value)
func (*Bool) DefaultValueString ¶
DefaultValueString string representation of the default value
func (*Bool) IsBoolValue ¶
IsBoolValue check if value is boolean
type Command ¶
type Command struct { Name string // Name of the command Description string // Description of the command Options []*Option // Eventual options bound to the command SubCommands []*Command // Eventual sub-commands Called bool }
Command a command, or subcommand, called by the user
func (*Command) WithCommands ¶
WithCommands add multiple sub-commands at once
func (*Command) WithOptions ¶
WithOptions add multiple options at once
type Flags ¶
type Flags struct { AppName string // application's name AppVersion string // application's version AppDescription string // application's description Options []*Option // application-level options Commands []*Command // available commands // contains filtered or unexported fields }
Flags main struct for setting up commands and options
func (*Flags) GetCalledCommand ¶
GetCalledCommand Get the called command, if any
func (*Flags) PrintHelpWithArgs ¶
PrintHelpWithArgs print the help information
func (*Flags) WithCommands ¶
WithCommands add a command to the main help object
func (*Flags) WithOptions ¶
WithOptions add one or more options to the main help object
type Float32 ¶
Float32 float32 option value (and default value)
func (*Float32) DefaultValueString ¶
DefaultValueString string representation of the default value
func (*Float32) IsBoolValue ¶
IsBoolValue check if value is boolean
type Float64 ¶
Float64 float64 option value (and default value)
func (*Float64) DefaultValueString ¶
DefaultValueString string representation of the default value
func (*Float64) IsBoolValue ¶
IsBoolValue check if value is boolean
type Int ¶
Int integer option value (and default value)
func (*Int) DefaultValueString ¶
DefaultValueString string representation of the default value
type Int64 ¶
Int64 64-bits option integer value (and default value)
func (*Int64) DefaultValueString ¶
DefaultValueString string representation of the default value
func (*Int64) IsBoolValue ¶
IsBoolValue check if value is boolean
type Option ¶
type Option struct { Short rune // Short option name (i.e. 'd') Long string // Long option name (i.e. "debug") Description string // Option's description (i.e. "Log debug messages") Value Value // Option's value and default value }
Option Application or command level option
func NewFloat32 ¶
NewFloat32 create an Float32 option
func NewFloat64 ¶
NewFloat64 create an Float64 option
type String ¶
String string option value (and default value)
func (*String) DefaultValueString ¶
DefaultValueString string representation of the default value
func (*String) IsBoolValue ¶
IsBoolValue check if value is boolean
type Uint ¶
Uint unsigned integer option value (and default value)
func (*Uint) DefaultValueString ¶
DefaultValueString string representation of the default value
func (*Uint) IsBoolValue ¶
IsBoolValue check if value is boolean
type Uint64 ¶
Uint64 64-bits unsigned integer option value (and default value)
func (*Uint64) DefaultValueString ¶
DefaultValueString string representation of the default value
func (*Uint64) IsBoolValue ¶
IsBoolValue check if value is boolean
type Value ¶
type Value interface { String() string // String representation of the value DefaultValueString() string // String representation of the default value // Set - Used to set from the application's arguments. // If RequiresValue() == true, ("true" or "") or "false" are expected Set(string) error IsBoolValue() bool // If it returns true and no parameter is specified, Set will be called with "true" }
Value all values must adhere to this interface