diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 701048151..0f548c90c 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -125,7 +125,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { // Function providing dynamic auto-completion completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { - return compInstall(args, toComplete) + return compInstall(args, toComplete, client) }) addInstallFlags(cmd.Flags(), client, valueOpts) @@ -233,8 +233,12 @@ func isChartInstallable(ch *chart.Chart) (bool, error) { } // Provide dynamic auto-completion for the install and template commands -func compInstall(args []string, toComplete string) ([]string, completion.BashCompDirective) { - if len(args) == 1 { +func compInstall(args []string, toComplete string, client *action.Install) ([]string, completion.BashCompDirective) { + requiredArgs := 1 + if client.GenerateName { + requiredArgs = 0 + } + if len(args) == requiredArgs { return compListCharts(toComplete, true) } return nil, completion.BashCompDirectiveNoFileComp diff --git a/cmd/helm/template.go b/cmd/helm/template.go index fbd6f57e2..1c34d7245 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -126,7 +126,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { // Function providing dynamic auto-completion completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { - return compInstall(args, toComplete) + return compInstall(args, toComplete, client) }) f := cmd.Flags()