Repository: helm/helm
File: pkg/cmd/flags.go (Go)

Code before:
	"helm.sh/helm/v4/pkg/helmpath"
	"helm.sh/helm/v4/pkg/kube"
	"helm.sh/helm/v4/pkg/postrenderer"
	"helm.sh/helm/v4/pkg/repo/v1"
)

const (
	outputFlag         = "output"
	postRenderFlag     = "post-renderer"
	postRenderArgsFlag = "post-renderer-args"
)

func addValueOptionsFlags(f *pflag.FlagSet, v *values.Options) {
	f.StringSliceVarP(&v.ValueFiles, "values", "f", []string{}, "specify values in a YAML file or a URL (can specify multiple)")
	f.StringArrayVar(&v.Values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
	f.StringArrayVar(&v.StringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
	f.StringArrayVar(&v.FileValues, "set-file", []string{}, "set values from respective files specified via the command line (can specify multiple or separate values with commas: key1=path1,key2=path2)")
	f.StringArrayVar(&v.JSONValues, "set-json", []string{}, "set JSON values on the command line (can specify multiple or separate values with commas: key1=jsonval1,key2=jsonval2 or using json format: {\"key1\": jsonval1, \"key2\": \"jsonval2\"})")
	f.StringArrayVar(&v.LiteralValues, "set-literal", []string{}, "set a literal STRING value on the command line")
}

func AddWaitFlag(cmd *cobra.Command, wait *kube.WaitStrategy) {
	cmd.Flags().Var(
		newWaitValue(kube.HookOnlyStrategy, wait),
		"wait",
		"wait until resources are ready (up to --timeout). Values: 'watcher', 'hookOnly' (default), and 'legacy'",
	)
	// Sets the strategy to use the watcher strategy if `--wait` is used without an argument
	cmd.Flags().Lookup("wait").NoOptDefVal = string(kube.StatusWatcherStrategy)
}

type waitValue kube.WaitStrategy

func newWaitValue(defaultValue kube.WaitStrategy, ws *kube.WaitStrategy) *waitValue {
	*ws = defaultValue
	return (*waitValue)(ws)
}

func (ws *waitValue) String() string {
	if ws == nil {
		return ""
	}
	return string(*ws)
}

func (ws *waitValue) Set(s string) error {
	switch s {
	case string(kube.StatusWatcherStrategy), string(kube.LegacyStrategy), string(kube.HookOnlyStrategy):
		*ws = waitValue(s)
		return nil
	case "true":

Review comment (suggestion):
As "Problem 2: Confusing CLI Mapping" points out, there are two "defaults". The default for when no flag is specified. And the default for when the flag is specified, but no value is provided (the result of convert from a boolean flag)

Thinking about how to represent these. Perhaps?:

```suggestion
		"if specified, wait until resources are ready (up to --timeout). Values: 'watcher' (default), 'hookOnly', and 'legacy'.",
```

Code after:
	"helm.sh/helm/v4/pkg/helmpath"
	"helm.sh/helm/v4/pkg/kube"
	"helm.sh/helm/v4/pkg/postrenderer"
	"helm.sh/helm/v4/pkg/repo/v1"
)

const (
	outputFlag         = "output"
	postRenderFlag     = "post-renderer"
	postRenderArgsFlag = "post-renderer-args"
)

func addValueOptionsFlags(f *pflag.FlagSet, v *values.Options) {
	f.StringSliceVarP(&v.ValueFiles, "values", "f", []string{}, "specify values in a YAML file or a URL (can specify multiple)")
	f.StringArrayVar(&v.Values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
	f.StringArrayVar(&v.StringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
	f.StringArrayVar(&v.FileValues, "set-file", []string{}, "set values from respective files specified via the command line (can specify multiple or separate values with commas: key1=path1,key2=path2)")
	f.StringArrayVar(&v.JSONValues, "set-json", []string{}, "set JSON values on the command line (can specify multiple or separate values with commas: key1=jsonval1,key2=jsonval2 or using json format: {\"key1\": jsonval1, \"key2\": \"jsonval2\"})")
	f.StringArrayVar(&v.LiteralValues, "set-literal", []string{}, "set a literal STRING value on the command line")
}

func AddWaitFlag(cmd *cobra.Command, wait *kube.WaitStrategy) {
	cmd.Flags().Var(
		newWaitValue(kube.HookOnlyStrategy, wait),
		"wait",
		"if specified, wait until resources are ready (up to --timeout). Values: 'watcher' (default), 'hookOnly', and 'legacy'.",
	)
	// Sets the strategy to use the watcher strategy if `--wait` is used without an argument
	cmd.Flags().Lookup("wait").NoOptDefVal = string(kube.StatusWatcherStrategy)
}

type waitValue kube.WaitStrategy

func newWaitValue(defaultValue kube.WaitStrategy, ws *kube.WaitStrategy) *waitValue {
	*ws = defaultValue
	return (*waitValue)(ws)
}

func (ws *waitValue) String() string {
	if ws == nil {
		return ""
	}
	return string(*ws)
}

func (ws *waitValue) Set(s string) error {
	switch s {
	case string(kube.StatusWatcherStrategy), string(kube.LegacyStrategy), string(kube.HookOnlyStrategy):
		*ws = waitValue(s)
		return nil
	case "true":