Report the flag name as typed in deprecation warnings - #500
Conversation
When a NormalizeFunc aliases a flag name, using the alias for a deprecated flag printed the canonical name rather than the one the user typed. Parse passed the normalized flag.Name into Set, so the typed name was lost before the warning was built. Thread the typed name through the internal parseFunc so the warning reports it. Long flags report the typed alias; shorthands keep the canonical long name. Public Set/ParseAll signatures are unchanged. Fixes spf13#279
|
Flagging that the red golangci-lint v2.7.2 can't read Go 1.27's export data ( Not asking anyone to fix the linter — just noting the PR isn't broken. Happy to rebase if a re-run would pick up a newer golangci-lint. |
|
Ah, thanks for flagging. I suppose we need to bump golangci-lint now that 1.27 is out, which rolls stable/oldstable build jobs one up. PR welcome, otherwise I'll get to it when I get to it 😅 |
|
Opened #508 for the golangci-lint bump. v2.13.2 is built with Kept it to the version bump so it doesn't collide with #451. |
Fixes #279.
With an alias from
SetNormalizeFunc, using the alias for a deprecated flag printed the canonical name rather than the one typed:Parse's callback passedflag.NameintoSet, so the typed name was gone before the warning was built. This threads the typed name through the internalparseFuncso the warning reports it. Long flags report the typed alias; shorthands keep the canonical long name (no alias to report). PublicSet/ParseAllsignatures are unchanged; callingSetdirectly with an alias now echoes that alias.Added
TestDeprecatedFlagUsageAlias.Used AI assistance on this; I reviewed and tested it.