-
Notifications
You must be signed in to change notification settings - Fork 0
Parameter types
There are two types of parameters available to the reader: flags and values parameters. Additionally, related to this are the remaining arguments.
A flag parameter is a simple boolean value.
The flag is set to true
if the corresponding parameter is present upon the command line, otherwise it is false
.
A values parameter allows a value to be passed to the reader, like a key-value-pair.
For example, if 'my-fruit' were declared as a values parameter then --my-fruit Banana
would pass the value "Banana" as the value for that parameter.
Values parameters may be declared and registered as value optional. Value-optional parameters are a hybrid of flags and values parameters.
If a value is specified for a value-optional parameter then it works the same as for a regular values parameter; the specified value is recorded against that parameter. If a value-optional parameter is present on the command-line but no value is supplied, then the value-optional parameter is interpreted to have received a value of an empty string.
Any information seen upon the command-line which did not correspond to registered parameters (or their values, for values parameters) is interpreted as 'remaining command-line arguments'. These arguments are placed by the reader into a list of strings, ordered by the order in which they appear on the command-line.
Remaining arguments may have parameters appearing before and after them on the command line. There is no requirement that they are presented before or after other parameters, or even that there are not parameters listed in the middle of them.