Struct OptionSet
Represents a set of parsed options.
public struct OptionSet
- Inherited Members
Constructors
OptionSet(IReadOnlyDictionary<Option, ParsedOption>)
Creates a parsed option set from a mapping of options to parsed options.
public OptionSet(IReadOnlyDictionary<Option, ParsedOption> contents)
Parameters
contentsIReadOnlyDictionary<Option, ParsedOption>A mapping of options to parsed options.
Methods
ContainsOption(Option)
Tells if this set of parsed options includes a particular option.
public bool ContainsOption(Option key)
Parameters
keyOptionThe option to examine.
Returns
- bool
trueif a form of the option has been parsed; otherwise,false.
GetValue(FlagOption)
Gets the Boolean value that has been parsed for a flag option. If there is no such value, then the flag's default value is returned.
public bool GetValue(FlagOption opt)
Parameters
optFlagOptionA flag option to find a parsed value for.
Returns
- bool
The parsed value or the flag's default value.
GetValue<T>(Option)
Gets the value that has been parsed for a particular option. If there is no such value, then the default value for that option is returned.
public T GetValue<T>(Option opt)
Parameters
optOptionAn option to find a parsed value for.
Returns
- T
The option's value if a form of the option has been parsed; otherwise, the option's default value
Type Parameters
T
Remarks
This method does not tell you whether the option was explicitly present on the command line. Use TryGetValue<T>(Option, out T) or ContainsOption(Option) when that distinction matters.
GetValue<T>(SequenceOption<T>)
Gets the values that have been parsed for a typed sequence option. If there is no such value, then the option's default value is returned.
public IReadOnlyList<T> GetValue<T>(SequenceOption<T> opt)
Parameters
optSequenceOption<T>A typed sequence option to find parsed values for.
Returns
- IReadOnlyList<T>
The parsed values or the option's default value.
Type Parameters
TThe option's element type.
GetValue<T>(ValueOption<T>)
Gets the value that has been parsed for a typed value option. If there is no such value, then the option's default value is returned.
public T GetValue<T>(ValueOption<T> opt)
Parameters
optValueOption<T>A typed value option to find a parsed value for.
Returns
- T
The parsed value or the option's default value.
Type Parameters
TThe option's value type.
TryGetParsedOption(Option, out ParsedOption)
Looks for the parsed option that corresponds to a particular option.
public bool TryGetParsedOption(Option key, out ParsedOption value)
Parameters
keyOptionThe option to find a parsed option for.
valueParsedOptionThe parsed option for the specified option.
Returns
- bool
trueif a parsed option is found that corresponds to the option; otherwise,false.
TryGetValue(FlagOption, out bool)
Looks for the Boolean value that has been parsed for a flag option. If there is no such value, then the flag's default value is produced.
public bool TryGetValue(FlagOption opt, out bool result)
Parameters
optFlagOptionA flag option to find a parsed value for.
resultboolThe resulting Boolean value.
Returns
- bool
trueif a form of the flag has been parsed; otherwise,false.
TryGetValue<T>(Option, out T)
Looks for the value that has been parsed for a particular option. If there is no such value, then the default value for that option is produced.
public bool TryGetValue<T>(Option opt, out T result)
Parameters
optOptionAn option to find a parsed value for.
resultTThe variable in which the resulting value is stored.
Returns
- bool
trueif a form of the option has been parsed; otherwise,false.
Type Parameters
T
TryGetValue<T>(SequenceOption<T>, out IReadOnlyList<T>)
Looks for the values that have been parsed for a typed sequence option. If there is no such value, then the option's default value is produced.
public bool TryGetValue<T>(SequenceOption<T> opt, out IReadOnlyList<T> result)
Parameters
optSequenceOption<T>A typed sequence option to find parsed values for.
resultIReadOnlyList<T>The resulting sequence of values.
Returns
- bool
trueif a form of the option has been parsed; otherwise,false.
Type Parameters
TThe option's element type.
TryGetValue<T>(ValueOption<T>, out T)
Looks for the value that has been parsed for a typed value option. If there is no such value, then the option's default value is produced.
public bool TryGetValue<T>(ValueOption<T> opt, out T result)
Parameters
optValueOption<T>A typed value option to find a parsed value for.
resultTThe resulting value.
Returns
- bool
trueif a form of the option has been parsed; otherwise,false.
Type Parameters
TThe option's value type.