-
Notifications
You must be signed in to change notification settings - Fork 2
Home
This library allows you to define the set of options accepted by a .NET console application by writing a driver class that contains methods that adhere to some simple conventions.
To declare the switches -h and --help, write this method:
[Description("Show help listing all available options")]
public void Help() { ... }and to declare the parameters -u <user> and --username <user>, write this method:
[Description("Specify the username for authentication")]
public void Username(string user) { ... }For more information on how this works, see the page on Conventions.
The design goals of this library:
- Simple conventions that "just work"
- Little to no dependency on the library
Between v1.0 and v2.0:
In v1 of the CommandLineProcessor, there was a new() generic type constraint and the processor took care of creating
the driver instance itself. This behaviour prevented the use of a dependency injection framework. The breaking change
in this release is to require your code to create the driver instance itself.
Modify this line:
var processor = new CommandLineProcessor<Driver>(args);to instead create the Driver itself:
var processor = new CommandLineProcessor<Driver>(args, new Driver());