Struct OptionSet

Namespace
Pixie.Options
Assembly
Pixie.dll

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

contents IReadOnlyDictionary<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

key Option

The option to examine.

Returns

bool

true if 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

opt FlagOption

A 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

opt Option

An 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

opt SequenceOption<T>

A typed sequence option to find parsed values for.

Returns

IReadOnlyList<T>

The parsed values or the option's default value.

Type Parameters

T

The 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

opt ValueOption<T>

A typed value option to find a parsed value for.

Returns

T

The parsed value or the option's default value.

Type Parameters

T

The 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

key Option

The option to find a parsed option for.

value ParsedOption

The parsed option for the specified option.

Returns

bool

true if 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

opt FlagOption

A flag option to find a parsed value for.

result bool

The resulting Boolean value.

Returns

bool

true if 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

opt Option

An option to find a parsed value for.

result T

The variable in which the resulting value is stored.

Returns

bool

true if 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

opt SequenceOption<T>

A typed sequence option to find parsed values for.

result IReadOnlyList<T>

The resulting sequence of values.

Returns

bool

true if a form of the option has been parsed; otherwise, false.

Type Parameters

T

The 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

opt ValueOption<T>

A typed value option to find a parsed value for.

result T

The resulting value.

Returns

bool

true if a form of the option has been parsed; otherwise, false.

Type Parameters

T

The option's value type.