Documentation ¶
Index ¶
- type Arg
- type Chad
- func (slf *Chad) BoolFlag(key string) bool
- func (slf *Chad) FloatFlag(key string) float64
- func (slf *Chad) FloatIndex(idx int) float64
- func (slf *Chad) FloatPosName(name string) float64
- func (slf *Chad) IntFlag(key string) int
- func (slf *Chad) IntIndex(idx int) int
- func (slf *Chad) IntPosName(name string) int
- func (slf *Chad) IsFlagDefault(key string) bool
- func (slf *Chad) IsFlagPresent(key string) bool
- func (slf *Chad) Parse()
- func (slf *Chad) ParseFromSlice(input []string)
- func (slf *Chad) ParseFromString(input string)
- func (slf *Chad) RegisterArgs(args []Arg, positionalNames []string)
- func (slf *Chad) StringFlag(key string) string
- func (slf *Chad) StringIndex(idx int) string
- func (slf *Chad) StringPosName(name string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chad ¶
type Chad struct { DefinedFlags map[string]Arg Result *parse.ParseResult ExpectedPositionalCount int PositionalNames []string // contains filtered or unexported fields }
A datastructure representing a true Chad. The Chad holds all important data for validation and parsed results after validation.
func NewChad ¶
func NewChad() *Chad
Usage:
chad := chad.NewChad() chad.RegisterArgs( []chad.Arg{ // These are our arguments. *chad.NewArg("file", "The file to be read", "default_filename", true), }, 0, // The number of positional arguments we expect. ) chad.Parse() // or any other parse<...> function.
Before parsing anything, you have to register the arguments for the validation process to be able to execute.
func (*Chad) FloatIndex ¶
Get a positional value my its index in form of a float64
func (*Chad) FloatPosName ¶
Get a positional value my its name in form of a float64
func (*Chad) IntPosName ¶
Get a positional value my its name in form of an int
func (*Chad) IsFlagDefault ¶
Check if a flag retained its default value.
func (*Chad) IsFlagPresent ¶
Check if a flag is present in the parsed arguments.
func (*Chad) ParseFromSlice ¶
Parse from an input string slice
func (*Chad) ParseFromString ¶
Parse from an input string
func (*Chad) RegisterArgs ¶
Register the arguments to be parsed. This allows for the validation of the arguments.
func (*Chad) StringFlag ¶
Get a flag's value by its name in form of a string
func (*Chad) StringIndex ¶
Get a positional value my its index in form of a string
func (*Chad) StringPosName ¶
Get a positional value my its name in form of a string