commandlineparser / commandlineparser/commandline

Can I add validate feature in Set parameter, and throw exception, and show usage?

Đang mở
#283 3 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ả

Can I add validate feature in Set parameter, and throw exception, and show usage?
is there exception handling in command line parameter parsing?

[Option(
'f', "filename",
HelpDesk = "Specifies the input file")]
public string Name
{
get { return mName; }
set
{
Regex regex = new Regex("^[0-9a-z]+.txt$");

if (regex.Match(value).Success )
throw new InvalidOptionValueException(
"The name must be txt file", false);
mName = value;
}
}
Private string mName;

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.