commandlineparser / commandlineparser/commandline

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

Open
#283 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.8k
Forks
478
PR merge metrics
No merged PRs in 30d

Description

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;

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.