Class GnuOptionSetParser

Namespace
Pixie.Options
Assembly
Pixie.dll

A parser for GNU-style option sets.

public sealed class GnuOptionSetParser : OptionSetParser
Inheritance
GnuOptionSetParser
Inherited Members

Constructors

GnuOptionSetParser(IReadOnlyList<Option>)

Creates a GNU-style option parser from a list of options. The option parser will reject positional arguments.

public GnuOptionSetParser(IReadOnlyList<Option> options)

Parameters

options IReadOnlyList<Option>

A list of all options known to this parser.

GnuOptionSetParser(IReadOnlyList<Option>, Option)

Creates a GNU-style option parser from a list of options and a default option.

public GnuOptionSetParser(IReadOnlyList<Option> options, Option defaultOption)

Parameters

options IReadOnlyList<Option>

A list of all options known to this parser.

defaultOption Option

The default option: the option that is implicitly parsed when no other option can accept arguments. Its first form is used to parse arguments.

GnuOptionSetParser(IReadOnlyList<Option>, Option, OptionForm)

Creates a GNU-style option parser from a list of options, a default option and a preferred form for that default option.

public GnuOptionSetParser(IReadOnlyList<Option> options, Option defaultOption, OptionForm defaultForm)

Parameters

options IReadOnlyList<Option>

A list of all options known to this parser.

defaultOption Option

The default option: the option that is implicitly parsed when no other option can accept arguments.

defaultForm OptionForm

The preferred form for the default option.

GnuOptionSetParser(IReadOnlyList<Option>, IReadOnlyList<KeyValuePair<Option, OptionForm>>)

Creates a GNU-style option parser from a list of options and a list of positional argument options.

public GnuOptionSetParser(IReadOnlyList<Option> options, IReadOnlyList<KeyValuePair<Option, OptionForm>> positionalOptions)

Parameters

options IReadOnlyList<Option>

A list of all options known to this parser.

positionalOptions IReadOnlyList<KeyValuePair<Option, OptionForm>>

A list of (Option, OptionForm) pairs that parse positional arguments.

Properties

Options

Gets a list of all options known to this parser.

public IReadOnlyList<Option> Options { get; }

Property Value

IReadOnlyList<Option>

A list of options.

PositionalOptions

Gets a list of (Option, OptionForm) pairs that parse positional arguments.

public IReadOnlyList<KeyValuePair<Option, OptionForm>> PositionalOptions { get; }

Property Value

IReadOnlyList<KeyValuePair<Option, OptionForm>>

The positional options.

Methods

Parse(IReadOnlyList<string>, ILog)

Parses an option set from a list of command-line arguments.

public override OptionSet Parse(IReadOnlyList<string> arguments, ILog log)

Parameters

arguments IReadOnlyList<string>

A list of command-line arguments.

log ILog

A log to which messages can be sent as arguments are parsed.

Returns

OptionSet

A parsed option set.

Remarks

Parsing problems are reported to log, but this method still returns an OptionSet so callers can choose whether to recover, continue with defaults, or abort based on the logged severities.