-
Notifications
You must be signed in to change notification settings - Fork 290
Description
Hey
Currently using version .1.9.71.
How can a make a boolean argument, and set is value to false?
I have tested with many combination, but no-matter what I tried, the value become always true, when I use the argument. Last test, I downloaded the source code.
I have notice that in class CommandLine.Parsing.LongOptionParser line 117, that a boolean value always set to true, no-mater which value that stand behind the option.
valueSetting = option.SetValue(true, options);
Here is what I have seen.
In my option class I have this
[Option('c', "cValue", Required = false, DefaultValue = true, HelpText = "Bool: Required = false, Default=true. Expected: true")]
public bool CValue_true { get; set; }
[Option('d', "dValue", Required = false, DefaultValue = false, HelpText = "Bool: Required = false, Default=false. Expected: false.")]
public bool DValue_false { get; set; }
If I now use the parser, with no argument, c become true, and d become false.
However, if I add these parameters "-d False" d always become true. Can't find a way to tell the CommandLineParser to make d false, nor c for that matter. Can only do it by using default values, and not include them in the argument list, but this can be right?
What am I doing wrong?
Jacob Mogensen
Activity
gsscoder commentedon Jun 24, 2015
@monze,
the syntax you quoted is not supported since the library implement
getopt()
*nix standard.In both version a scalar boolean is false only when omitted and set
true
when specified:As now 2.0.x-pre is quite usable so I suggest you to use the new version (possibly building from sources, just executing
packages\FAKE...\tools\Fake.exe
from cloned repo).There's actually more than an issue/discussion on allowing an explicit
false
value or use a common pattern ofapp c+
\app c-
.For the moment the priority is to promote current 2.0 pre-release to an higher level of stability, like alpha.
gsscoder commentedon Jun 24, 2015
Please refer to:
#158
and
#133
I've to close the issue since it's a duplicate, but feel free to add comments (better if in issue #158).