Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteArguments ¶
func ExecuteArguments(parsedArgs ParsedArguments)
Types ¶
type Flag ¶
type Flag struct {
Description string
// All possible flags that can trigger this option
// // for --help
// []string{"-H", "-?"}
Aliases []string
// All the inputs in the order to expect them in
//
// If, for example, the first input's validator returned false
// and the input after it returned true,
// the next arg will be evaluated by the third input
Inputs InputOrder
Action func(instance Instance)
}
type Input ¶
type Input struct {
Name string
Description string
// Is this input required to be present?
//
// If the input is not present after the flag, the program will panic and log an error specifying which input was expected
Required bool
// The maximum amount of times that this input can be repeated as long as the validator returns true foe each of them.
//
// 0 will be interperted as 1, this is to allow this field to be ommited.
//
// -1 for unlimeted
MaxOccurences int
// Specify a function that can validate a potential input.
//
// If ommited, the input will always be valid given that the arg is not a defined flag
Validator func(arg string) bool
}
type InputOrder ¶
type InputOrder []Input
func (InputOrder) String ¶
func (this InputOrder) String() string
type Instance ¶
type Instance struct {
// The index at which this instance occurred
Index int
// The arg that was used to trigger this instances definition
Arg string
// All the args that followed that are defined and validated to be inputs for this flag
Inputs MInputInstances
}
type MFlags ¶
A map of argument options that define all options for the current program
The key of the map will also be its default usage as an argument but with '--' infront of it
{ "flag-name": MFlags{...} }
type MInputInstances ¶
func (MInputInstances) String ¶
func (this MInputInstances) String() string
type MInstances ¶
All arg instances grouped by their arg definition key
func (MInstances) String ¶
func (this MInstances) String() string
type ParsedArguments ¶
type ParsedArguments struct {
//TODO Find better wording for this comment:
// The unedited arguments as they were passed in at the launch of the program
Raw []string
// The path to the file that is currently running.
SourceFile string
// The definitions of all possible argument flags and their implimentations
Definitions MFlags
// All arg instances that were present
Args MInstances
}
func ParseArguments ¶
func ParseArguments(args []string, definitions MFlags) (parsed ParsedArguments)
func (ParsedArguments) String ¶
func (this ParsedArguments) String() string