-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Description
Follows #2301.
I have a bit of a situation where translation of long flags is desired but short flags is not.
If you have something like this in your CLI:
rootCmd.PersistentFlags().BoolVarP(
&internal.Help,
i18n.G("help"),
"h", // not translated
false,
i18n.G("help for myCli"),
)And you translate "help" to "ayuda". Then in InitDefaultHelpFlag π
Line 1221 in 61968e8
| if c.Flags().Lookup(helpFlagName) == nil { |
helpFlagName is no longer "help" and the code attempts to set c.Flags().BoolP(helpFlagName, "h", false, usage). However, -h is already set and we see an explosion stacktrace:
panic: unable to redefine 'h' shorthand in "myCli" flagset: it's already used for "ayuda" flag
This is quite an edge-case but just another symptom of cobra not supporting i18n natively.
Just wanted to report that in.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels