commandlineparser / commandlineparser/commandline

Converting from 1.9.71 to 2.9.1, having issues.

Đang mở
#846 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C#
Star
4.8k
Fork
478
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hello. I am attempting to upgrade my commandlineparser code to the latest version and I am struggling.

The program's requirements are pretty simple: must have one and only one parameter, with a choice between two options.

Here is what I would ultimately like to have:

[Option("daysback", Required = false, Group = "onerequired", SetName = "daysback", Min = 0, Max = 999, HelpText = "Number of days back in time for run date.")]
public int? DaysBack { get; set; }

[Option("date", Required = false, Group = "onerequired", SetName = "date", HelpText = "Specific date for run date (yyyymmdd).")]
public string RunDate { get; set; }

Group would require at least one parameter, setname would make them mutually exclusive, max and min would check a value.

Unfortunately (according to docs), group and setname cannot be used together, so I had to drop group. And, min/max cannot be used on an int argument, so also dropped.

So now we look like this:

[Option("daysback", Required = false, SetName = "daysback", HelpText = "Number of days back in time for run date.")]
public int? DaysBack { get; set; }

[Option("date", Required = false, SetName = "date", HelpText = "Specific date for run date (yyyymmdd).")]
public string RunDate { get; set; }

Which is okay, but means that I have more checking to do myself.

Two questions please:

1. As is, this will parse cleanly if no arguments are given. Is there a way to set max/min number of required arguments?
2. Is there a way to generate the help screen text on demand? If I find argument errors with my post-parse checking, I'd like to output the same help screen that commandlineparser does.

Thanks.

Bryan Hunt

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.