Documentation
¶
Index ¶
- func AllowOnlyOneTopLevelArgument() parseOption
- func AllowTopLevelArgumentWithoutName() parseOption
- func DontRemoveFirstArgument() parseOption
- func RequireAtleastOneTopLevelArgument() parseOption
- type AntArg
- func (a AntArg) Equal(b AntArg) bool
- func (antArg *AntArg) NewArg(name string, help string, isFlag bool, shortcut string, numberOfValues int) (*Arg, error)
- func (antArg *AntArg) Parse(arguments []string, parseOptions ...parseOption) error
- func (antArg AntArg) Prettify() string
- func (antArg AntArg) PrintArgumentInformation()
- type Arg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowOnlyOneTopLevelArgument ¶
func AllowOnlyOneTopLevelArgument() parseOption
func AllowTopLevelArgumentWithoutName ¶
func AllowTopLevelArgumentWithoutName() parseOption
func DontRemoveFirstArgument ¶
func DontRemoveFirstArgument() parseOption
func RequireAtleastOneTopLevelArgument ¶
func RequireAtleastOneTopLevelArgument() parseOption
Types ¶
type AntArg ¶
type AntArg struct {
// contains filtered or unexported fields
}
AntArg is the main struct when working with AntArg package. It contains an array of arguments of the using program, as well as information about the program.
func New ¶
New initializes an instance of AntArgs, should be used for creating the main program AntArg instance
func (*AntArg) NewArg ¶
func (antArg *AntArg) NewArg(name string, help string, isFlag bool, shortcut string, numberOfValues int) (*Arg, error)
NewArg initializes a new argument tied to a parent AntArg
func (*AntArg) Parse ¶
Parse takes an array of string arguments assigns the arguments to their corresponding value in the AntArg object.
parseOptions can be provided to control the parsing: AllowOnlyOneTopLevelArgument() = Will return error if more than 1 argument is provided at the top level (AntArg.args) DontRemoveFirstArgument() = Will disable the default behavior to remove the first element of the argument array RequireAtleastOneTopLevelArgument() = Will return error if no argument has been provided AllowTopLevelArgumentWithoutName() = Will allow the top level arguments to be provided with only values, this will assume no top level argument is provided with name, and that the values are provided in the order that the arguments was provided into the AntArgs object
The following errors can be returned: "No argument supplied" = Will happen if RequireOneTopLevelArgument parseOption was requested and no argument was provided "%s it not a valid argument" = Will happen if a top level argument was supplied but no corresponding argument was declared in the AntAr "Only one top level argument is allowed" == Will happening if more than 1 top level argument was provided and the parseOption AllowonlyOneTopLevelArgument was request
func (AntArg) PrintArgumentInformation ¶
func (antArg AntArg) PrintArgumentInformation()
type Arg ¶
type Arg struct {
// contains filtered or unexported fields
}
Arg is the struct containing a specific argument for an AntArg list of arguments
func (*Arg) NewSubArg ¶
func (arg *Arg) NewSubArg(name string, help string, isFlag bool, shortcut string, numberOfValues int) (*Arg, error)
NewSubArg initializes a new argument tied to a parent arg
func (Arg) PrintSubArgumentInformation ¶
func (arg Arg) PrintSubArgumentInformation()