When you create a new instance of
AppRunner<T> you can pass an instance new
Here are the settings you can change:
Show argument details#
Shows type information of arguments in help text. Enabled by default.
Method argument mode#
Possible values :
- Parameter (default)
When method argument mode is set to parameter, all arguments of methods are treated as parameters and don't need any names to be passed through command line.
Order of passing parameters matter in this mode
When method argument mode is set to option, all arguments of methods are treated as options and need a name to be passed.
This is only applicable for methods and not constructors. For constructors, all arguments are options only
Enable version option#
True by default. It adds an additional option to the root command. It shows version of the application.
1 2 3 4 5 6 7 8 9 10 11 12
by default this would result into something like this:
1 2 3 4 5 6 7 8 9 10
Command line conventions are different from C# conventions and the usual pascal casing of method names or camel casing of parameter names may not be suitable for command line arguments.
You can continue to develop you classes and method in normal C# conventions and tell library to transform them into the desired casing.
There are 5 modes available:
If you now use a different setting,
1 2 3 4 5 6 7 8 9 10 11
The result would something like this:
1 2 3 4 5 6 7 8 9 10
This would not transform any name that you have overridden via
In this library, there are two ways to parse boolean Options
Boolean mod is applicable only for
Options and not for
This is the default mode.
In this mode, you don't pass the value
false in the command line. These parameters are treated as flags. They are considered
true if they are present and
false when they are not.
In this case, value of parameter
printValues will be true
and in the following example,
value of parameter
printValues will be false.
When using implicit boolean mode, it will result in an error, if the user tries to explicitly enter a value for parameter. In this instance,
dotnet example.dll --printValues true will result into an error.
When you check the help of a command, you if you see
Flag for a parameter, it means value is implit and does not require an explicit one.
Clubbing of one letter options is supported. For example,
These can be passed either as
If you want users to explicitly enter true or false, you need to set the boolean mode explicit. You can do that, by using the
[Argument] attribute as shown below:
1 2 3 4
You can set
BooleanMode = BooleanMode.Implicit or
BooleanMode = BooleanMode.Explicit only for
bool? type options.
When you use explicit boolean mode, these scenarios are valid:
1 2 3
dotnet example.dll MyCommand --capturelogs is not valid and will result into error. It will only work in Implicit boolean mode.
When you check the help of a command, and you see
Boolean it means if you wan't to make it true, you need to pass an explicit value. If you don't pass one, it will default to
false automatically. Implicit and explicit are just ways to pass the value, under the hood they are just boolean parameters.