Table of Contents

Class ArgumentsBuilder

Namespace
Webefinity.Switch
Assembly
Switch.dll

A fluent builder for setting up options and their value providers.

public class ArgumentsBuilder
Inheritance
ArgumentsBuilder
Inherited Members

Constructors

ArgumentsBuilder()

Construct a new argument builder, taking command line arguments from Environment.GetCommandLineArgs. You can override this argument source after construction by calling SetArguments.

public ArgumentsBuilder()

Methods

Add(string, char?, bool)

Add an option. This returns and ArgumentOption which can be extended via a variety of fluent methods

public ArgumentOption Add(string longVersion, char? shortVersion = null, bool isDefault = false)

Parameters

longVersion string

The long form flag as a string, without the leading --.

shortVersion char?

A short form flag as a char, without the leading -, or null if there is no short form.

isDefault bool

True if this is a default option (the value can be passed as the first argument without the flag.

Returns

ArgumentOption

An ArgumentOption, for fluid extension.

Exceptions

MultipleDefaultsException

Thrown if more than one default option is added.

Build()

Construct a handler and parse the arguments using the options. Calling Build causes the arguments to be validated and the time Build is called.

public ArgumentsHandler Build()

Returns

ArgumentsHandler

The handler, which contains information about validity and the values of the arguments

SetArguments(params string[])

Override the arguments used after construction of the builder. Useful for test cases.

public void SetArguments(params string[] args)

Parameters

args string[]

The arguments to use instead of the environment arguments.