Skip to content

The use the bool values #174

Closed
Closed
@monze

Description

@monze

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions