Skip to content

Fix: show full option name in error for unknown multi-char short options#3395

Closed
afsar-hussai wants to merge 1 commit intopallets:mainfrom
afsar-hussai:fix/multichar-short-option-error-message
Closed

Fix: show full option name in error for unknown multi-char short options#3395
afsar-hussai wants to merge 1 commit intopallets:mainfrom
afsar-hussai:fix/multichar-short-option-error-message

Conversation

@afsar-hussai
Copy link
Copy Markdown

When an unknown multi-character short option like -dbg is passed, click shows "No such option: -d" instead of "No such option:
-dbg". Only the first character was shown, which is misleading.

Fixed by passing the full original argument to NoSuchOption in _match_short_opt instead of the single-character opt.

Added a test test_unknown_multichar_short_option_shows_full_name to verify the fix.

fixes #2779

… multichar short opts

When an unknown multi-character short option like `-dbg` was passed, the
error message incorrectly showed only the first character: "No such option: -d."
This change passes the full original argument to NoSuchOption so the message
correctly shows "No such option: -dbg."

Fixes pallets#2779
@davidism davidism closed this Apr 30, 2026
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

Successfully merging this pull request may close these issues.

Wrong error message when wrong multicharacter short option is passed

2 participants