Documentation
¶
Overview ¶
Package commander contains a simple command-line argument parser that supports flags, switches and free-form trailing (and mid-stream) arguments, and provides methods for their retrieval.
Commander provides similar functionality to the flags package, but also supports 'schemaless' argument parsing, where the structure of arguments might not be known up front. It supports user-defined, key-value style arguments — for example, as 'myapp -key1=value1 --key2 value2', where key1 and key2 could be anything.
Index ¶
Constants ¶
const FreeForm = "__free_form"
FreeForm is a key in PartsMap for free-form (trailing) values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Part ¶
type Part struct {
Name, Value string
}
Part is a tuple of parsed arguments.
For named arguments — for example, the argument pair '-key=value' or '-key value', the Name field is 'key' (i.e. without the leading dash or pair of dashes) and the Value field is simply 'value'. For free-form (a.k.a. trailing) arguments — for example, 'file1.txt', the Name field is a blank string and the Value field contains the argument.
func (Part) IsFreeForm ¶
IsFreeForm return true if this is a free-form part.
type Parts ¶
type Parts []Part
Parts is a slice of Part tuples.