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

Nested command option shadowing -h prints wrong suggestion #2790

Open
tumidi opened this issue Oct 21, 2024 · 0 comments
Open

Nested command option shadowing -h prints wrong suggestion #2790

tumidi opened this issue Oct 21, 2024 · 0 comments

Comments

@tumidi
Copy link

tumidi commented Oct 21, 2024

Click prints an incorrect suggestion when using a combination of nested command and required argument. This happens when the nested command shadows the -h option shortcut of the main command which Click apparently tolerates.

Replication

See https://github.com/tumidi/click-subcommand-help-message.

$ click-test-cli foo
Usage: click-test-cli foo [OPTIONS] REQUIRED_ARG
Try 'click-test-cli foo -h' for help.

Error: Missing argument 'REQUIRED_ARG'.

But, actually running the suggested click-test-cli foo -h prints

$ click-test-cli foo -h
Error: Option '-h' requires an argument.

Interestingly, Click correctly detects the shadowing of the option when printing the foo command help and prints a consistent help page.

$ click-test-cli foo --help
Usage: click-test-cli foo [OPTIONS] REQUIRED_ARG

Options:
  -h, --host TEXT
  --help           Show this message and exit.

Possible solutions

Fix the generated message, so it prints Try 'click-test-cli foo --help' for help. in this case.

Environment:

  • Python version: 3.12.6
  • Click version: 8.2.0.dev0 d73083e
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

1 participant