commandlineparser / commandlineparser/commandline

Parsing FlagCounter argument fails with `isDefault` Verb

Aperta
#888 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C#
Stelle
4.8k
Fork
478
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.