CommandLineParser(Type, ParseOptions) Constructor

Initializes a new instance of the CommandLineParser class using the specified arguments type and options.

Definition

Namespace: Ookii.CommandLine
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.2.0+a4d3631e4dcc0970081ed435288efdebc1325f83
C#
public CommandLineParser(
	Type argumentsType,
	ParseOptions? options = null
)

Parameters

argumentsType  Type
The Type of the class that defines the command line arguments.
options  ParseOptions  (Optional)
The options that control parsing behavior, or to use the default options.

Remarks

  Note

Instead of this constructor, it's recommended to use the CommandLineParserT class instead.

This constructor uses reflection to determine the arguments defined by the type indicated by argumentsType at runtime, unless the type has the GeneratedParserAttribute applied. For a type using that attribute, you can also use the generated static IParserProviderTSelfCreateParser(ParseOptions) or IParserTSelfParse(ParseOptions) methods on the arguments class instead.

If the options parameter is not , the instance passed in will be modified to reflect the options from the arguments class's ParseOptionsAttribute attribute, if it has one.

Certain properties of the ParseOptions class can be changed after the CommandLineParser class has been constructed, and still affect the parsing behavior. See the Options property for details.

Exceptions

ArgumentNullExceptionargumentsType is .
NotSupportedException The CommandLineParser cannot use argumentsType as the command line arguments type, because it violates one of the rules concerning argument names or positions, or has an argument type that cannot be parsed.

See Also