Skip to content
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

For some options, errors in the parse result results in their associated actions instead of ParseErrorAction #2498

Open
barrygiles opened this issue Oct 16, 2024 · 1 comment

Comments

@barrygiles
Copy link

I expect this is by design but was a surprise to me and I don't fully understand the motivations behind it.

Passing an additional parameter to a sub command results in an error in the parse result and a ParseErrorAction, which when invoked, prints out the error.

Passing an additional parameter to --version or --help also results in an error in the parse result, but the action is HelpAction or VersionOptionAction, which either prints help or the version without any mention of the parse error.

This seems inconsistent to me, but I'm guessing there might be conventions around this I'm not aware of.
I could probably intercept the parse result in these circumstances and invoke a manually created ParseErrorAction or something similar, but this might be a bit messy and might be unnecessary if there are good reasons to stick with this behaviour.

Using System.CommandLine 2.0.0-beta4.24324.3.

@KalleOlaviNiemitalo
Copy link

Seems consistent with GNU diffutils at least:

$ diff a b c d
diff: extra operand 'c'
diff: Try 'diff --help' for more information.
$ diff a b c d --help
Usage: diff [OPTION]... FILES
Compare FILES line by line.
[…]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants