commandlineparser / commandlineparser/commandline

How to add constraints to an int option?

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

描述

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?

贡献指南

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

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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