commandlineparser / commandlineparser/commandline

How to add constraints to an int option?

Aperta
#905 1 commento 6 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

Is it possible to set constraints to an int option so that it have min and max allowed values? I think that's a pretty common scenario, but the following fails:

```csharp
[Option('q', "quality", Default = 80, Min = 1, Max = 100)]
public int Quality { get; set; }

```
With this exception: `System.InvalidOperationException: Scalar option specifications do not support range specification.`

If the library does not provide this functionality how would I implement it on my own and still play nicely with the auto help and error messages that the library automatically outputs on invalid input?

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.