commandlineparser / commandlineparser/commandline

Parsing FlagCounter argument fails with `isDefault` Verb

Aberta
#888 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
C#
Estrelas
4.8k
Forks
478
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Start with the provided C# reproduction and compare ParseArguments using the default verb and FlagCounter against the explicit-verb, single-flag, and non-verb cases. Done means the default-verb case parses "-vv" successfully without reporting Option 'v' as defined multiple times.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
csharp
Domínio
cli
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
45/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.