Alias Option

Represents one program options. One of more of these can be given to a ProgramOptions object as template arguments.

alias Option(string name, T) = OptionImpl!(name,T);

If the option name is not a valid identifier, it is transformed in to camel case by the following rules:

  1. if first character is invalid first character for identifier, it is skipped.
  2. if any following character is not a valid identifier character, it is skipped AND the next valid character is capitalized.

Parameters

NameDescription
name The name of the options
T The type of this variable

Named optional arguments

A number of named optional arguments can be given to an Option for e.g.:

ProgramOptions!(
    Option!("optionName", bool).shortName!"o";
);

This will create an options object that can parse --optionName and -o on the command line.

The following named optional arguments are available:

  • shortName: string - the short name for the option, multiple short names can be specified like a|b|c.
  • longName: string - If you want multiple long names, or you want to set the longName to nil.
  • defaultValue: T - the default value if not supplied
  • description: string - description for help message
  • environmentVar: string - the name of the environment var that can set this option if present
  • caseSensitiveLongName: bool - true if long name is case sensitive
  • caseSensitiveShortName: bool - true if short name is case sensitive
  • incremental: bool - true if this option represents an incremental value
  • validator: bool function(T) - a function that will be given the value and must return true if the value is valid
  • seperator: string - the seperator used to parse associative array values
  • parser: T function(string) - a function that must return a T after parsing the string
  • bundleable: bool - true if this short option can be bundled with other short options
  • duplicatePolicy: OptionDuplicatePolicy - what to do when the option is encoutered for a second time