Skip to content

fix: reject single-dash long flag names#474

Closed
leno23 wants to merge 1 commit into
spf13:masterfrom
leno23:fix/reject-single-dash-long-flag-2358
Closed

fix: reject single-dash long flag names#474
leno23 wants to merge 1 commit into
spf13:masterfrom
leno23:fix/reject-single-dash-long-flag-2358

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

-name and -name=value are no longer parsed as shorthand -n plus a value suffix when name is a registered long flag. Users get an explicit error to use --name instead.

Go test flags (-test.*) continue to work via the existing test. prefix exemption.

Tests

  • TestParseRejectsSingleDashLongFlag

Fixes spf13/cobra#2358

Made with Cursor

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

When an argument matches a registered long flag name but uses one
leading dash (e.g. -name), return a clear error instead of parsing it
as shorthand plus a value suffix. Go test flags (-test.*) are exempt.

Fixes spf13/cobra#2358
@leno23 leno23 force-pushed the fix/reject-single-dash-long-flag-2358 branch from 52db632 to 67350f5 Compare May 17, 2026 15:51
@tomasaschan
Copy link
Copy Markdown
Collaborator

This is the same change as #473, rejected for the same reason.

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.

long flags, that were accidentally using only one hyphen, are mistreated

3 participants