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

Parser still recognizes --help option even when i set the parser setting "AutoHelp" to false #596

Open
elgonzo opened this issue Mar 12, 2020 · 2 comments

Comments

@elgonzo
Copy link

elgonzo commented Mar 12, 2020

(CommandlineParser version 2.7.82)

When using a parser with the AutoHelp setting set to false i would expect the parser to not recognize the --help option unless i have it explicitly declared as part of my options class. If i have no such declaration, i would expect the parser to treat --help as an unknown option/error. Unfortunately, this is not the case. The parser still recognizes this option, even when AutoHelp is set to false :(

The documentation comment for AutoHelp (also shown by Intellisense) seems to support my expectations:

Gets or sets a value indicating whether implicit option or verb 'help' should be supported.

But that does not seem to be what that setting actually does...

Thus my question: What is the actual purpose and supposed effect of setting AutoHelp for the parser to false? And how would i make --help not an option?

For example, if i use the unknown option --foo, the HelpText.AutoBuild method is able to generate a text containing:

ERROR(S):
  Option 'foo' is unknown.

I want to get the same result when calling my program with the (unknown) option --help:

ERROR(S):
  Option 'help' is unknown.

Unfortunately, the parser or HelpText.AutoBuild method seem to refuse to treat --help as an unknown option (both parser settings AutoHelp and IgnoreUnknownArguments are set to false)
:-(

@rmunn
Copy link
Contributor

rmunn commented Mar 17, 2020

It looks like I'm indirectly responsible for causing this behavior to happen, actually. In gsscoder/commandline#225, I asked for "Option 'help' is unknown" to NOT show up when running a verb-based command like "my-cmd verb arg --help". The solution that was implemented at the time was a band-aid that filters out UnknownOptionError if (and only if) the unknown option in question is the "--help" option.

The real solution is to not use a bandaid, but to handle the --help option properly, recognizing it anywhere in the command line instead of just in the first position. This will involve changing some of the preprocessor code as well as the "filter out UnknownOptionError" bandaid. I'll open a new issue to track that, because that's not quite the same issue as the one you're complaining about here.

@rmunn
Copy link
Contributor

rmunn commented Mar 17, 2020

I've created #600 as a design document to discuss the right solution, BTW.

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