![]() |
BadScript 2
|
Provides methods to parse command line arguments. More...
Public Member Functions | |
Parser () | |
Initializes a new instance of the CommandLine.Parser class. | |
Parser (Action< ParserSettings > configuration) | |
Initializes a new instance of the Parser class, configurable with ParserSettings using a delegate. | |
Parser (Func< ParserSettings > factory) | |
void | Dispose () |
Frees resources owned by the instance. | |
ParserResult< T > | ParseArguments< T > (IEnumerable< 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. | |
ParserResult< T > | ParseArguments< T > (Func< T > factory, IEnumerable< 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. | |
ParserResult< object > | ParseArguments (IEnumerable< 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. | |
Package Functions | |
Parser (ParserSettings settings) | |
Properties | |
static Parser | Default [get] |
Gets the singleton instance created with basic defaults. | |
ParserSettings | Settings [get] |
Gets the instance that implements CommandLine.ParserSettings in use. | |
Private Member Functions | |
~Parser () | |
Finalizes an instance of the CommandLine.Parser class. | |
void | Dispose (bool disposing) |
Static Private Member Functions | |
static Result< IEnumerable< Token >, Error > | Tokenize (IEnumerable< string > arguments, IEnumerable< OptionSpecification > optionSpecs, ParserSettings settings) |
static ParserResult< T > | MakeParserResult< T > (ParserResult< T > parserResult, ParserSettings settings) |
static ParserResult< T > | DisplayHelp< T > (ParserResult< T > parserResult, TextWriter helpWriter, int maxDisplayWidth) |
static IEnumerable< ErrorType > | HandleUnknownArguments (bool ignoreUnknownArguments) |
Private Attributes | |
bool | disposed |
Static Private Attributes | |
static readonly Lazy< Parser > | DefaultParser |
CommandLine.Parser.Parser | ( | ) |
Initializes a new instance of the CommandLine.Parser class.
Definition at line 30 of file Parser.cs.
CommandLine.Parser.Parser | ( | Action< ParserSettings > | configuration | ) |
Initializes a new instance of the Parser class, configurable with ParserSettings using a delegate.
configuration | The Action<ParserSettings> delegate used to configure aspects and behaviors of the parser. |
CommandLine.Parser.Parser | ( | Func< ParserSettings > | factory | ) |
|
package |
|
private |
Finalizes an instance of the CommandLine.Parser class.
|
staticprivate |
Definition at line 273 of file Parser.cs.
void CommandLine.Parser.Dispose | ( | ) |
|
private |
Definition at line 295 of file Parser.cs.
|
staticprivate |
|
staticprivate |
ParserResult< object > CommandLine.Parser.ParseArguments | ( | IEnumerable< 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.
args | A System.String array of command line arguments, normally supplied by application entry point. |
types | A System.Type array used to supply verb alternatives. |
System.ArgumentNullException | Thrown if one or more arguments are null. |
System.ArgumentOutOfRangeException | Thrown if types array is empty. |
All types must expose a parameterless constructor. It's strongly recommended to use a generic overload.
Definition at line 216 of file Parser.cs.
ParserResult< T > CommandLine.Parser.ParseArguments< T > | ( | Func< T > | factory, |
IEnumerable< 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.
T | Type of the target instance built with parsed value. |
factory | A System.Func<T> delegate used to initialize the target instance. |
args | A System.String array of command line arguments, normally supplied by application entry point. |
System.ArgumentNullException | Thrown if one or more arguments are null. |
Definition at line 164 of file Parser.cs.
ParserResult< T > CommandLine.Parser.ParseArguments< T > | ( | IEnumerable< 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.
T | Type of the target instance built with parsed value. |
args | A System.String array of command line arguments, normally supplied by application entry point. |
System.ArgumentNullException | Thrown if one or more arguments are null. |
Definition at line 120 of file Parser.cs.
|
staticprivate |
Definition at line 249 of file Parser.cs.
|
staticprivate |
|
staticget |
|
get |
Gets the instance that implements CommandLine.ParserSettings in use.
Definition at line 80 of file Parser.cs.