Class Option

Namespace
Pixie.Options
Assembly
Pixie.dll

Describes a command-line option.

public abstract class Option
Inheritance
Option
Derived
Inherited Members

Constructors

Option()

protected Option()

Properties

DefaultValue

Gets the option's default value.

public abstract object DefaultValue { get; }

Property Value

object

The default value.

Documentation

Gets the option's documentation.

public abstract OptionDocs Documentation { get; }

Property Value

OptionDocs

The documentation for the option.

Forms

Gets a list of all forms this option accepts.

public abstract 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 abstract OptionParser CreateParser(OptionForm form)

Parameters

form OptionForm

The form to parse.

Returns

OptionParser

An option parser.

Flag(params string[])

Creates a simple flag option from command-line spellings such as -h or --help.

public static FlagOption Flag(params string[] forms)

Parameters

forms string[]

The forms accepted by the option.

Returns

FlagOption

A flag option.

Int32(params string[])

Creates a 32-bit integer option with a default value of zero.

public static ValueOption<int> Int32(params string[] forms)

Parameters

forms string[]

The forms accepted by the option.

Returns

ValueOption<int>

A 32-bit integer option.

Int32Sequence(params string[])

Creates a 32-bit integer sequence option from command-line spellings.

public static SequenceOption<int> Int32Sequence(params string[] forms)

Parameters

forms string[]

The forms accepted by the option.

Returns

SequenceOption<int>

A 32-bit integer sequence option.

Int32WithDefault(int, params string[])

Creates a 32-bit integer option from command-line spellings such as -O.

public static ValueOption<int> Int32WithDefault(int defaultValue, params string[] forms)

Parameters

defaultValue int

The option's default value.

forms string[]

The forms accepted by the option.

Returns

ValueOption<int>

A 32-bit integer option.

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 abstract ParsedOption MergeValues(ParsedOption first, ParsedOption second)

Parameters

first ParsedOption

The first parsed option.

second ParsedOption

The second parsed option.

Returns

ParsedOption

A composite parsed option.

Sequence<T>(Func<OptionForm, string, ILog, T>, params string[])

Creates a typed sequence option from command-line spellings.

public static SequenceOption<T> Sequence<T>(Func<OptionForm, string, ILog, T> parseArgument, params string[] forms)

Parameters

parseArgument Func<OptionForm, string, ILog, T>

A function that parses each argument.

forms string[]

The forms accepted by the option.

Returns

SequenceOption<T>

A typed sequence option.

Type Parameters

T

The parsed element type.

String(params string[])

Creates a string option with an empty-string default value.

public static ValueOption<string> String(params string[] forms)

Parameters

forms string[]

The forms accepted by the option.

Returns

ValueOption<string>

A string option.

StringSequence(params string[])

Creates a string sequence option from command-line spellings such as --file.

public static SequenceOption<string> StringSequence(params string[] forms)

Parameters

forms string[]

The forms accepted by the option.

Returns

SequenceOption<string>

A string sequence option.

StringWithDefault(string, params string[])

Creates a string option from command-line spellings such as --color.

public static ValueOption<string> StringWithDefault(string defaultValue, params string[] forms)

Parameters

defaultValue string

The option's default value.

forms string[]

The forms accepted by the option.

Returns

ValueOption<string>

A string option.

Toggle(string, string, bool)

Creates a flag option with explicit positive and negative forms.

public static FlagOption Toggle(string positiveForm, string negativeForm, bool defaultValue = false)

Parameters

positiveForm string

The form that enables the flag.

negativeForm string

The form that disables the flag.

defaultValue bool

The default value for the flag.

Returns

FlagOption

A flag option.

Value<T>(Func<OptionForm, string, ILog, T>, T, params string[])

Creates a typed value option from command-line spellings.

public static ValueOption<T> Value<T>(Func<OptionForm, string, ILog, T> parseArgument, T defaultValue, params string[] forms)

Parameters

parseArgument Func<OptionForm, string, ILog, T>

A function that parses the option's argument.

defaultValue T

The option's default value.

forms string[]

The forms accepted by the option.

Returns

ValueOption<T>

A typed option.

Type Parameters

T

The parsed value type.