commandlineparser / commandlineparser/commandline

Parsing FlagCounter argument fails with `isDefault` Verb

未关闭
#888 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C#
星标
4.8k
派生
478
PR 合并指标
30 天内没有已合并 PR

描述

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(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(args)`, the sample above completes and successfully parses the flag value.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。