func addStringSliceFlag(cmd *cobra.Command, name string, def []string, desc string, opts ...flagOpt) { fn := flagName(cmd, name) cmd.Flags().StringSlice(name, def, desc) viper.BindPFlag(fn, cmd.Flags().Lookup(name)) for _, o := range opts { o(cmd, name, fn) } }
func cmdNS(cmd *cobra.Command) string { parentName := doit.NSRoot if cmd.Parent() != nil { parentName = cmd.Parent().Name() } return fmt.Sprintf("%s.%s", parentName, cmd.Name()) }
func flagName(cmd *cobra.Command, name string) string { parentName := doit.NSRoot if cmd.Parent() != nil { parentName = cmd.Parent().Name() } return fmt.Sprintf("%s.%s.%s", parentName, cmd.Name(), name) }