From c4722bc00d9d6c5214920b1a1ec789ab6321938d Mon Sep 17 00:00:00 2001 From: Luc DUZAN Date: Wed, 20 Mar 2024 17:09:23 +0100 Subject: [PATCH] Fail on incomplete command --- cmd/get.go | 6 ++++++ cmd/root.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/cmd/get.go b/cmd/get.go index 5df9fa4..5c0f579 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -9,6 +9,12 @@ import ( var getCmd = &cobra.Command{ Use: "get", Short: "get resource of a given kind", + Args: cobra.NoArgs, + Run: func(cmd *cobra.Command, args []string) { + // Root command does nothing + cmd.Help() + os.Exit(1) + }, } var getCmdWhenNoSchema = &cobra.Command{ diff --git a/cmd/root.go b/cmd/root.go index 86d8ac5..e40f985 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -28,6 +28,11 @@ You can also use the CDK_KEY,CDK_CERT instead of --key and --cert flags to use a apiClient.ActivateDebug() } }, + Run: func(cmd *cobra.Command, args []string) { + // Root command does nothing + cmd.Help() + os.Exit(1) + }, // Uncomment the following line if your bare application // has an action associated with it: // Run: func(cmd *cobra.Command, args []string) { },