From e2d5ec8397b69a375a307e2fee93e32fc0b13de9 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 10 Oct 2019 05:32:11 -0400 Subject: [PATCH] feat(comp): Dynamic completion for --output flag (#6580) Signed-off-by: Marc Khouzam --- cmd/helm/flags.go | 2 ++ cmd/helm/root.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index 09676e658..32d5b891b 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -52,6 +52,8 @@ func addChartPathOptionsFlags(f *pflag.FlagSet, c *action.ChartPathOptions) { // value to the given format pointer func bindOutputFlag(cmd *cobra.Command, varRef *output.Format) { cmd.Flags().VarP(newOutputValue(output.Table, varRef), outputFlag, "o", fmt.Sprintf("prints the output in the specified format. Allowed values: %s, %s, %s", output.Table, output.JSON, output.YAML)) + // Setup shell completion for the flag + cmd.MarkFlagCustom(outputFlag, "__helm_output_options") } type outputValue output.Format diff --git a/cmd/helm/root.go b/cmd/helm/root.go index eccb49fa0..e28e8bdfb 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -89,6 +89,12 @@ __helm_get_namespaces() fi } +__helm_output_options() +{ + __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" + COMPREPLY+=( $( compgen -W "table json yaml" -- "$cur" ) ) +} + __helm_binary_name() { local helm_binary