Skip to content

fix help hint showing shadowed option name#3208

Open
Mr-Neutr0n wants to merge 1 commit intopallets:stablefrom
Mr-Neutr0n:fix/help-option-shadowing-suggestion
Open

fix help hint showing shadowed option name#3208
Mr-Neutr0n wants to merge 1 commit intopallets:stablefrom
Mr-Neutr0n:fix/help-option-shadowing-suggestion

Conversation

@Mr-Neutr0n
Copy link
Copy Markdown

Fixes #2790.

When a subcommand defines an option that shadows one of the configured help option names (e.g. -h), the error hint was still suggesting the shadowed name:

Try 'cli foo -h' for help.

But -h is now the subcommand's --host option, not help. Running cli foo -h gives Error: Option '-h' requires an argument. instead of showing help.

The fix uses get_help_option_names() which already exists and filters out names claimed by other parameters. So now the hint picks a working alternative like --help:

Try 'cli foo --help' for help.

@kdeldycke kdeldycke changed the base branch from main to stable April 16, 2026 09:34
@kdeldycke kdeldycke added this to the 8.4.0 milestone Apr 21, 2026
@kdeldycke kdeldycke force-pushed the fix/help-option-shadowing-suggestion branch from b981ca9 to 10841e5 Compare April 21, 2026 15:57
@kdeldycke
Copy link
Copy Markdown
Collaborator

I just reworked that PR to be more resilient against various cases of default option names overriding. Also added unittests to illustrate all these edge-cases.

@kdeldycke kdeldycke added bug f:help feature: help text labels Apr 21, 2026
Fix pallets#2790.

Co-authored-by: Mr-Neutr0n <64578610+Mr-Neutr0n@users.noreply.github.com>
@kdeldycke kdeldycke force-pushed the fix/help-option-shadowing-suggestion branch from 10841e5 to 1241aba Compare April 21, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug f:help feature: help text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested command option shadowing -h prints wrong suggestion

2 participants