Build an option from a Perl-like string syntax
The definition must match the following regular expression syntax: ^[\w|]+([:=+][sifd]?)?$
.
Explanation:
Part | Description |
---|---|
[\w|]+ | A series of one or more word or character names separated by pipe ('|') characters. Example: help|h|? . In this example, for Unix-style options, the valid option variations would be: --help, -h or -?
|
[:=+] | A character to define the type of value expected. This is optional, and if not given, the option will be considered a flag. So a definition of help can be given at the command-line like: Program --help . The ':' and '=' requires the type of value (see below). The '+' can be used in two ways. First, it can mean that a flag can be given multiple times (to be counted for example). This usage: verbose+ can be given like: Program --verbose --verbose --verbose to result in a verbosity of 3. With a type of value (see below), it means that the option can have many values. A value of ':' means the option may take a value, and '=' means that a value is required for this option. |
[sifd]? | A character to define the type of data to accept. This is optional if the preceding character is '+' (see above). If given, the values map to the following .NET types: s - String, i - Int32, d - Double and f - Float |
Flag: Example show help: help|h|? Flag that gets counted: Example to set level of verbosity: verbose|v+ Option with a required string value (Example: set an output directory): Example to set an output directory: directory|dir|d=s Option with an optional integer value: Example to count value that defaults to 0: count|c:i Option that accepts multiple string values: Example to specify include patters: include|i+s
OptionDefinition Class | CommandLine.OptParse Namespace | OptionDefinition Constructor Overload List