-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I add validate feature in Set parameter, and throw exception, and show usage? #283
Comments
No, there is no such exception handling. try
{
var result = Parser.Default.ParseArguments(...);
}
catch (InvalidOperationException e)
{
if (e.InnerException is TargetInvocationException targetInvocationException)
{
var innerException = targetInvocationException.InnerException;
Console.Error.WriteLine(innerException.Message);
}
} P.S. I will try to implement this feature now. |
e673
added a commit
to e673/commandline
that referenced
this issue
May 5, 2018
…s parsing errors ToDo: add tests and nameinfo
e673
added a commit
to e673/commandline
that referenced
this issue
May 5, 2018
I've implementing it here: |
I just tried this and it works as expected! Thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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$");
}
Private string mName;
The text was updated successfully, but these errors were encountered: