Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing FlagCounter argument fails with isDefault Verb #888

Open
wondras4 opened this issue Apr 24, 2023 · 0 comments
Open

Parsing FlagCounter argument fails with isDefault Verb #888

wondras4 opened this issue Apr 24, 2023 · 0 comments

Comments

@wondras4
Copy link

wondras4 commented Apr 24, 2023

Parsing FlagCounter arguments fail, when used together with default Verb feature with following error

ERROR(S):
  Option 'v' is defined multiple times.

code sample:

[Verb("option", isDefault: true)]
class Options
{
    [Option('v', FlagCounter = true)]
    public int Verbose { get; set; }
}

class Program
{
    static int Main(string[] args)
    {
        args = "-vv".Split(' ');
        var parser = new Parser(opts => { opts.GetoptMode = true; });
        var parsed = parser.ParseArguments<Options, object>(args);
		
        Console.WriteLine(parsed.Value == null ? "Parsing failed" : "Flag parsed");		
        return 0;
    }
}

When either specifying Verb explicitly (args = "option -vv"), or when counter value is <= 1 (args = "-v") or when not using Verbs parsing parser.ParseArguments<Options>(args), the sample above completes and successfully parses the flag value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant