-
Notifications
You must be signed in to change notification settings - Fork 481
CommandLine.HelpRequestedError and CommandLine.VersionRequestedError #630
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
Comments
yes |
I just changed my code to handle these. bool stopProcessing = false;
Parser.Default.ParseArguments<CommandLineOptions>(args)
.WithNotParsed(o =>
{
List<Error> errors = o.ToList();
stopProcessing = errors.Any(e => e.StopsProcessing);
if (errors.Any(e => e.Tag == ErrorType.HelpRequestedError || e.Tag == ErrorType.VersionRequestedError))
{
return;
}
foreach (Error error in errors)
{
Console.WriteLine($"Error command line parameter '{error.Tag}'");
}
})
.WithParsed(o => CommandLineOptions = o);
if (stopProcessing)
{
return 1;
} |
I don't understand why this is considered as an error by default ? |
You mean there is something not right in my code yet? |
For me, when the application is started with the verb "help", the "error" tag is not e.Tag == ErrorType.HelpRequestedError like in your example, but e.Tag == ErrorType.HelpVerbRequestedError. |
I stumbled into this too. Imho, I used the same workaround as @KoalaBear84 which works for me because there is no verb |
Just an FYI it's actually slightly worse than what's above. help/--help doesn't give you the |
Not sure it is already under consideration!
ProgXYZ --version
ProgXYZ --help
invokes WithNotParsed and list contains error HelpRequestedError and VersionRequestedError
The text was updated successfully, but these errors were encountered: