Skip to content

fix: reject single-dash long flag spellings#473

Closed
leno23 wants to merge 2 commits into
spf13:masterfrom
leno23:fix/long-flag-single-dash-2358
Closed

fix: reject single-dash long flag spellings#473
leno23 wants to merge 2 commits into
spf13:masterfrom
leno23:fix/long-flag-single-dash-2358

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

Fixes spf13/cobra#2358.

Arguments like -name that match a long flag name now return a helpful error instead of being parsed as shorthand -n with value ame.

Test plan

  • go test ./...

Made with Cursor

leno23 and others added 2 commits May 17, 2026 19:07
Fixes spf13#415 and spf13#456.

Skip empty string values when parsing StringArray flags so `--flag=""`
does not produce a single empty entry. Update README to show SortFlags on
a FlagSet instead of the package level.

Co-authored-by: Cursor <cursoragent@cursor.com>
Fixes spf13/cobra#2358.

When an argument like `-name` matches a registered long flag name,
return a clear error instead of parsing it as shorthand `-n` with value
`ame`.

Co-authored-by: Cursor <cursoragent@cursor.com>
@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.

@tomasaschan
Copy link
Copy Markdown
Collaborator

This change would make this library less POSIX compatible, which breaks the entire purpose of it. (One can discuss to what extent it already breaks POSIX, but we shouldn't make it worse.)

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