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 👇
|
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.
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:
And you translate
"help"to"ayuda". Then inInitDefaultHelpFlag👇cobra/command.go
Line 1221 in 61968e8
helpFlagNameis no longer"help"and the code attempts to setc.Flags().BoolP(helpFlagName, "h", false, usage). However,-his already set and we see an explosion stacktrace:This is quite an edge-case but just another symptom of cobra not supporting i18n natively.
Just wanted to report that in.