Skip to content

fix: use full argument in NoSuchOption for short options#3232

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

fix: use full argument in NoSuchOption for short options#3232
RogueTex wants to merge 1 commit intopallets:mainfrom
RogueTex:fix/short-option-error-message

Conversation

@RogueTex
Copy link

Summary

Fixes #2779 - when a multi-character short option like -dbgwrong is passed and not found, the error message previously showed only the first character (e.g., No such option: -d) instead of the full argument.

Root cause: _match_short_opt iterated over single characters and raised NoSuchOption(opt) where opt was the single-char option string. The arg parameter (the full original argument) was available but unused in the error.

Fix: Pass arg instead of opt to NoSuchOption, so users see the full string they typed.

Before:

Error: No such option: -d

After:

Error: No such option: -dbgwrong

Closes #2779

Refactor error handling for unknown options in parser.
@davidism davidism closed this Feb 26, 2026
@pallets pallets temporarily blocked RogueTex Feb 26, 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