Class Option
Describes a command-line option.
public abstract class Option
- Inheritance
-
Option
- Derived
-
ValueOption<T>
- Inherited Members
Constructors
Option()
protected Option()
Properties
DefaultValue
Gets the option's default value.
public abstract object DefaultValue { get; }
Property Value
- object
The default value.
Documentation
Gets the option's documentation.
public abstract OptionDocs Documentation { get; }
Property Value
- OptionDocs
The documentation for the option.
Forms
Gets a list of all forms this option accepts.
public abstract IReadOnlyList<OptionForm> Forms { get; }
Property Value
- IReadOnlyList<OptionForm>
The option's forms.
Methods
CreateParser(OptionForm)
Create a parser for one of this option's forms.
public abstract OptionParser CreateParser(OptionForm form)
Parameters
formOptionFormThe form to parse.
Returns
- OptionParser
An option parser.
Flag(params string[])
Creates a simple flag option from command-line spellings such as
-h or --help.
public static FlagOption Flag(params string[] forms)
Parameters
formsstring[]The forms accepted by the option.
Returns
- FlagOption
A flag option.
Int32(params string[])
Creates a 32-bit integer option with a default value of zero.
public static ValueOption<int> Int32(params string[] forms)
Parameters
formsstring[]The forms accepted by the option.
Returns
- ValueOption<int>
A 32-bit integer option.
Int32Sequence(params string[])
Creates a 32-bit integer sequence option from command-line spellings.
public static SequenceOption<int> Int32Sequence(params string[] forms)
Parameters
formsstring[]The forms accepted by the option.
Returns
- SequenceOption<int>
A 32-bit integer sequence option.
Int32WithDefault(int, params string[])
Creates a 32-bit integer option from command-line spellings such as
-O.
public static ValueOption<int> Int32WithDefault(int defaultValue, params string[] forms)
Parameters
Returns
- ValueOption<int>
A 32-bit integer option.
MergeValues(ParsedOption, ParsedOption)
Merges the values of two parsed options. Both have forms that belong to this option. These forms may or may not be the same.
public abstract ParsedOption MergeValues(ParsedOption first, ParsedOption second)
Parameters
firstParsedOptionThe first parsed option.
secondParsedOptionThe second parsed option.
Returns
- ParsedOption
A composite parsed option.
Sequence<T>(Func<OptionForm, string, ILog, T>, params string[])
Creates a typed sequence option from command-line spellings.
public static SequenceOption<T> Sequence<T>(Func<OptionForm, string, ILog, T> parseArgument, params string[] forms)
Parameters
parseArgumentFunc<OptionForm, string, ILog, T>A function that parses each argument.
formsstring[]The forms accepted by the option.
Returns
- SequenceOption<T>
A typed sequence option.
Type Parameters
TThe parsed element type.
String(params string[])
Creates a string option with an empty-string default value.
public static ValueOption<string> String(params string[] forms)
Parameters
formsstring[]The forms accepted by the option.
Returns
- ValueOption<string>
A string option.
StringSequence(params string[])
Creates a string sequence option from command-line spellings such as
--file.
public static SequenceOption<string> StringSequence(params string[] forms)
Parameters
formsstring[]The forms accepted by the option.
Returns
- SequenceOption<string>
A string sequence option.
StringWithDefault(string, params string[])
Creates a string option from command-line spellings such as
--color.
public static ValueOption<string> StringWithDefault(string defaultValue, params string[] forms)
Parameters
Returns
- ValueOption<string>
A string option.
Toggle(string, string, bool)
Creates a flag option with explicit positive and negative forms.
public static FlagOption Toggle(string positiveForm, string negativeForm, bool defaultValue = false)
Parameters
positiveFormstringThe form that enables the flag.
negativeFormstringThe form that disables the flag.
defaultValueboolThe default value for the flag.
Returns
- FlagOption
A flag option.
Value<T>(Func<OptionForm, string, ILog, T>, T, params string[])
Creates a typed value option from command-line spellings.
public static ValueOption<T> Value<T>(Func<OptionForm, string, ILog, T> parseArgument, T defaultValue, params string[] forms)
Parameters
parseArgumentFunc<OptionForm, string, ILog, T>A function that parses the option's argument.
defaultValueTThe option's default value.
formsstring[]The forms accepted by the option.
Returns
- ValueOption<T>
A typed option.
Type Parameters
TThe parsed value type.