I am trying to use bool argument in my console application. I'm using the CommandLineParser Package, but parser return error.
this is my option
[Option("randomize", Required = false, DefaultValue = false, HelpText = "Enter \"true\" for the random selection")]
public bool Randomize { get; set; }
argument: --randomize=true
I am using Parser.Default.ParseArguments
Any idea why this doesn't work?
You don't need to add true or false as the argument value - CommandLineParser will just set the value to true if the argument is present.
So this will pass in a value of true:
--randomize
So if your application is called ParserApp the following passes true
ParserApp --randomize
While the below line will pass false
ParserApp
The Quick Start guide has an example for the usage of a boolean parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With