Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Parameter types

Craig Fowler edited this page Jan 27, 2017 · 1 revision

Parameter types

There are two types of parameters available to the reader: flags and values parameters. Additionally, related to this are the remaining arguments.

Flags parameters

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.

Values parameters

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.

Optional values

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.

Remaining arguments

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.

Clone this wiki locally