commandlineparser / commandlineparser/commandline

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

Đang mở
#596 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C#
Star
4.8k
Fork
478
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

(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](https://github.com/commandlineparser/commandline/blob/017a8a21c79b223fbcd541187c7dd546c18ebdda/src/CommandLine/ParserSettings.cs#L140-L142) 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`)
:-(

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.