normalize flag names so that underscores are interchangeable with hyphens

This commit is contained in:
Kovid Goyal
2022-08-17 15:46:15 +05:30
parent 2d466f343d
commit 2ca8ae8e5f
2 changed files with 5 additions and 2 deletions

View File

@@ -402,6 +402,9 @@ func Init(root *cobra.Command) {
root.SetHelpFunc(show_help)
root.SetHelpCommand(&cobra.Command{Hidden: true})
root.CompletionOptions.DisableDefaultCmd = true
root.SetGlobalNormalizationFunc(func(fs *pflag.FlagSet, name string) pflag.NormalizedName {
return pflag.NormalizedName(strings.ReplaceAll(name, "_", "-"))
})
}
func Execute(root *cobra.Command) error {