nemec / clipr

Command Line Interface ParseR for .Net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple positional arguments not working for negative numbers

dwrogers opened this issue · comments

The current first example:

        var opt = CliParser.Parse<Options>("-vvv output.txt 1 2 -1 7".Split());

fails with the message: "Additional information: Extra positional arguments found: -1 7"

    [PositionalArgument(1, MetaVar = "N",
        NumArgs = 1,
        Constraint = NumArgsConstraint.AtLeast,
        Description = "Numbers to sum.")]
    public List<int> Numbers { get; set; }

"-1" is treated as a new argument. I'm not inputting negative numbers as positionals, so I'll move on. But I thought I would point out this interesting problem.

David

commented

That will teach me to always add README examples to my unit tests. Thanks for pointing out this issue!

The parser piece handling variable arguments would terminate parsing when it saw a - without checking that it was a negative number (unlike parsing an exact number of arguments). I've fixed the issue in the source, but I haven't uploaded a new NuGet package.