From 8f962a270c65e703b07fb749f80ed67855d92f23 Mon Sep 17 00:00:00 2001 From: Xiangxuan Liu Date: Thu, 21 Nov 2019 16:24:12 +0800 Subject: [PATCH 1/2] Return "unknown command" error for unknown subcommands Signed-off-by: Xiangxuan Liu --- cmd/helm/root.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 3c6a0d18e..3ebea3bae 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -26,7 +26,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/clientcmd" - "helm.sh/helm/v3/cmd/helm/require" "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/internal/experimental/registry" "helm.sh/helm/v3/pkg/action" @@ -77,7 +76,6 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string Short: "The Helm package manager for Kubernetes.", Long: globalUsage, SilenceUsage: true, - Args: require.NoArgs, BashCompletionFunction: completion.GetBashCustomFunction(), } flags := cmd.PersistentFlags() From d5a2963cc95027951ea9654210786c639d5891ff Mon Sep 17 00:00:00 2001 From: Xiangxuan Liu Date: Fri, 22 Nov 2019 10:56:39 +0800 Subject: [PATCH 2/2] Add test for unknown subcommand Signed-off-by: Xiangxuan Liu --- cmd/helm/root_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/helm/root_test.go b/cmd/helm/root_test.go index df592a96d..e1fa1fc27 100644 --- a/cmd/helm/root_test.go +++ b/cmd/helm/root_test.go @@ -95,3 +95,11 @@ func TestRootCmd(t *testing.T) { }) } } + +func TestUnknownSubCmd(t *testing.T) { + _, _, err := executeActionCommand("foobar") + + if err == nil || err.Error() != `unknown command "foobar" for "helm"` { + t.Errorf("Expect unknown command error, got %q", err) + } +}