commandline icon indicating copy to clipboard operation
commandline copied to clipboard

Case sensitivity settings not respected

Open refactorsaurusrex opened this issue 10 years ago • 0 comments

This example is taken straight out of the documentation. Doesn't matter if I explicitly set CaseSensitive = false or use the default options, "bye" will not parse to GreetType.Bye. However, "Bye" does work correctly. I tried this in version 2.0 and 2.1.

class Program
{
    // Args: -g bye
    static void Main(string[] args)
    {
        var parser = new Parser(x => x.CaseSensitive = false);
        // ArgumentException: Requested value 'bye' was not found.
        var result1 = parser.ParseArguments<Options>(args);

        // ArgumentException: Requested value 'bye' was not found.
        var result2 = CommandLine.Parser.Default.ParseArguments<Options>(args);
    }
}

class Options
{
    [Option('g', "greet-type")]
    public GreetType SpecifiedGreetType { get; set; }
}

enum GreetType
{
    Hello,
    Bye,
    Regards
}

refactorsaurusrex avatar Aug 19 '15 22:08 refactorsaurusrex