Class ValueOption<T>
Describes a value option: an option takes exactly one argument.
public sealed class ValueOption<T> : Option
Type Parameters
T
- Inheritance
-
ValueOption<T>
- Inherited Members
Constructors
ValueOption(OptionForm, Func<OptionForm, string, ILog, T>, T)
Creates a value option from an option form, a function that parses an argument and a default value.
public ValueOption(OptionForm form, Func<OptionForm, string, ILog, T> parseArgument, T defaultValue)
Parameters
formOptionFormThe option's form.
parseArgumentFunc<OptionForm, string, ILog, T>A function that parses a string argument.
defaultValueTA default value for the value option.
ValueOption(IReadOnlyList<OptionForm>, Func<OptionForm, string, ILog, T>, T)
Creates a value option from a list of forms, a function that parses an argument and a default value.
public ValueOption(IReadOnlyList<OptionForm> forms, Func<OptionForm, string, ILog, T> parseArgument, T defaultValue)
Parameters
formsIReadOnlyList<OptionForm>The list of forms that the value option accepts.
parseArgumentFunc<OptionForm, string, ILog, T>A function that parses a string argument.
defaultValueTA default value for the value option.
Properties
DefaultValue
Gets the option's default value.
public override object DefaultValue { get; }
Property Value
- object
The default value.
Documentation
Gets the option's documentation.
public override OptionDocs Documentation { get; }
Property Value
- OptionDocs
The documentation for the option.
Forms
Gets a list of all forms this option accepts.
public override 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 override OptionParser CreateParser(OptionForm form)
Parameters
formOptionFormThe form to parse.
Returns
- OptionParser
An option parser.
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 override ParsedOption MergeValues(ParsedOption first, ParsedOption second)
Parameters
firstParsedOptionThe first parsed option.
secondParsedOptionThe second parsed option.
Returns
- ParsedOption
A composite parsed option.
WithCategory(string)
Creates a copy of this option that is classified under a particular category.
public ValueOption<T> WithCategory(string category)
Parameters
categorystringThe new option's category.
Returns
- ValueOption<T>
An option.
WithDescription(Block)
Creates a copy of this option that has a particular description.
public ValueOption<T> WithDescription(Block description)
Parameters
descriptionBlockThe new option's description.
Returns
- ValueOption<T>
An option.
WithParameter(OptionParameter)
Creates a copy of this option that has a particular parameter.
public ValueOption<T> WithParameter(OptionParameter parameter)
Parameters
parameterOptionParameterThe new option's sole parameter.
Returns
- ValueOption<T>
An option.
WithParameter(string)
Creates a copy of this option that has a symbolic parameter.
public ValueOption<T> WithParameter(string name)
Parameters
namestringThe parameter's display name.
Returns
- ValueOption<T>
An option.