From a7d6820d53e057023846dc44a21ed3f20949e9f8 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sat, 9 Mar 2019 15:54:18 -0500 Subject: [PATCH] Add completion for helm status Signed-off-by: Marc Khouzam --- cmd/helm/helm.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index b815568cb..656308d6d 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -39,6 +39,30 @@ import ( "k8s.io/helm/pkg/tlsutil" ) +const ( + bashCompletionFunc = ` +__helm_status_list() +{ + local out + if out=$(helm list -q 2>/dev/null); then + COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) + fi +} + +__helm_custom_func() +{ + case ${last_command} in + helm_status) + __helm_status_list + return + ;; + *) + ;; + esac +} +` +) + var ( tillerTunnel *kube.Tunnel settings helm_env.EnvSettings @@ -103,6 +127,7 @@ func newRootCmd(args []string) *cobra.Command { PersistentPostRun: func(*cobra.Command, []string) { teardown() }, + BashCompletionFunction: bashCompletionFunc, } flags := cmd.PersistentFlags()