CommandLine
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
Public Member Functions | Properties | List of all members
CommandLine.Parser Class Reference

Provides methods to parse command line arguments. More...

Inheritance diagram for CommandLine.Parser:

Public Member Functions

 Parser ()
 Initializes a new instance of the CommandLine.Parser class. More...
 
 Parser (Action< ParserSettings > configuration)
 Initializes a new instance of the Parser class, configurable with ParserSettings using a delegate. More...
 
ParserResult< T > ParseArguments< T > (string[] args)
 Parses a string array of command line arguments constructing values in an instance of type T . Grammar rules are defined decorating public properties with appropriate attributes. More...
 
ParserResult< T > ParseArguments< T > (Func< T > factory, string[] args)
 Parses a string array of command line arguments constructing values in an instance of type T . Grammar rules are defined decorating public properties with appropriate attributes. More...
 
ParserResult< object > ParseArguments (string[] args, params Type[] types)
 Parses a string array of command line arguments for verb commands scenario, constructing the proper instance from the array of types supplied by types . Grammar rules are defined decorating public properties with appropriate attributes. The CommandLine.VerbAttribute must be applied to types in the array. More...
 
void Dispose ()
 Frees resources owned by the instance. More...
 

Properties

static Parser Default [get]
 Gets the singleton instance created with basic defaults. More...
 
ParserSettings Settings [get]
 Gets the instance that implements CommandLine.ParserSettings in use. More...
 

Detailed Description

Provides methods to parse command line arguments.

Constructor & Destructor Documentation

CommandLine.Parser.Parser ( )
inline

Initializes a new instance of the CommandLine.Parser class.

CommandLine.Parser.Parser ( Action< ParserSettings configuration)
inline

Initializes a new instance of the Parser class, configurable with ParserSettings using a delegate.

Parameters
configurationThe Action&lt;ParserSettings&gt; delegate used to configure aspects and behaviors of the parser.

Member Function Documentation

void CommandLine.Parser.Dispose ( )
inline

Frees resources owned by the instance.

ParserResult<object> CommandLine.Parser.ParseArguments ( string[]  args,
params Type[]  types 
)
inline

Parses a string array of command line arguments for verb commands scenario, constructing the proper instance from the array of types supplied by types . Grammar rules are defined decorating public properties with appropriate attributes. The CommandLine.VerbAttribute must be applied to types in the array.

Parameters
argsA System.String array of command line arguments, normally supplied by application entry point.
typesA System.Type array used to supply verb alternatives.
Returns
A CommandLine.ParserResult{T} containing the appropriate instance with parsed values as a System.Object and a sequence of CommandLine.Error.
Exceptions
System.ArgumentNullExceptionThrown if one or more arguments are null.
System.ArgumentOutOfRangeExceptionThrown if types array is empty.

All types must expose a parameterless constructor. It's stronly recommended to use a generic overload.

ParserResult<T> CommandLine.Parser.ParseArguments< T > ( string[]  args)
inline

Parses a string array of command line arguments constructing values in an instance of type T . Grammar rules are defined decorating public properties with appropriate attributes.

Template Parameters
TType of the target instance built with parsed value.
Parameters
argsA System.String array of command line arguments, normally supplied by application entry point.
Returns
A CommandLine.ParserResult{T} containing an instance of type T with parsed values and a sequence of CommandLine.Error.
Exceptions
System.ArgumentNullExceptionThrown if one or more arguments are null.
Type Constraints
T :new() 
ParserResult<T> CommandLine.Parser.ParseArguments< T > ( Func< T >  factory,
string[]  args 
)
inline

Parses a string array of command line arguments constructing values in an instance of type T . Grammar rules are defined decorating public properties with appropriate attributes.

Template Parameters
TType of the target instance built with parsed value.
Parameters
factoryA System.Func{T} delegate used to intitalize the target instance.
argsA System.String array of command line arguments, normally supplied by application entry point.
Returns
A CommandLine.ParserResult{T} containing an instance of type T with parsed values and a sequence of CommandLine.Error.
Exceptions
System.ArgumentNullExceptionThrown if one or more arguments are null.

Property Documentation

Parser CommandLine.Parser.Default
staticget

Gets the singleton instance created with basic defaults.

ParserSettings CommandLine.Parser.Settings
get

Gets the instance that implements CommandLine.ParserSettings in use.


The documentation for this class was generated from the following file: