commandlineparser / commandlineparser/commandline
How to add constraints to an int option?
- Linguagem predominante
- C#
- Estrelas
- 4.8k
- Forks
- 478
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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?
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Start by tracing the Option attribute and the scalar option specification path that raises the range-specification exception. Then inspect how the library generates help and invalid-input errors; done means integer min/max constraints are supported while those existing outputs remain consistent.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp
- Domínio
- cli
- Tipo de issue
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100