Class OptionParseResult

Namespace
Pixie.Options
Assembly
Pixie.dll

Represents the outcome of parsing a command line.

public sealed class OptionParseResult
Inheritance
OptionParseResult
Inherited Members

Constructors

OptionParseResult(OptionSet, IReadOnlyList<LogEntry>, bool, int, bool, bool)

Creates a parse result from parsed options and recorded diagnostics.

public OptionParseResult(OptionSet options, IReadOnlyList<LogEntry> diagnostics, bool wasHandled, int exitCode, bool wasHelpRequested, bool wasVersionRequested)

Parameters

options OptionSet

The parsed options.

diagnostics IReadOnlyList<LogEntry>

The diagnostics emitted while parsing.

wasHandled bool

Tells if parsing already handled a conventional exit path, such as printing generated help or version information.

exitCode int

The recommended process exit code.

wasHelpRequested bool

Tells if the help option was requested.

wasVersionRequested bool

Tells if the version option was requested.

Properties

Diagnostics

Gets the diagnostics emitted while parsing.

public IReadOnlyList<LogEntry> Diagnostics { get; }

Property Value

IReadOnlyList<LogEntry>

The diagnostics emitted while parsing.

ExitCode

Gets the exit code associated with this parse result.

public int ExitCode { get; }

Property Value

int

The recommended exit code.

IsSuccess

Tells if parsing succeeded without errors.

public bool IsSuccess { get; }

Property Value

bool

true if no errors were emitted while parsing; otherwise, false.

Options

Gets the parsed options.

public OptionSet Options { get; }

Property Value

OptionSet

The parsed options.

WasHandled

Tells if parsing already handled a conventional exit path, such as printing generated help or version information. This is typically true when WasHelpRequested or WasVersionRequested is true. It is typically false for ordinary successful parses, where the caller should continue running the command, and also for parse failures, where IsSuccess is false.

public bool WasHandled { get; }

Property Value

bool

true if parsing printed a built-in terminal response and the caller will usually want to return immediately; otherwise, false.

WasHelpRequested

Tells if the help option was requested.

public bool WasHelpRequested { get; }

Property Value

bool

true if help was requested; otherwise, false.

WasVersionRequested

Tells if the version option was requested.

public bool WasVersionRequested { get; }

Property Value

bool

true if version information was requested; otherwise, false.

Methods

Contains(Severity)

Tests if parsing emitted at least one diagnostic of a particular severity.

public bool Contains(Severity severity)

Parameters

severity Severity

The severity to look for.

Returns

bool

true if parsing emitted a diagnostic of the requested severity; 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 option's default value is returned.

public T GetValue<T>(Option opt)

Parameters

opt Option

An 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.

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.

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 option's default value 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 resulting value.

Returns

bool

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

Type Parameters

T

The option's value type.

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.