From 77369b85762d265755c8120ff85a1f3903d6adb4 Mon Sep 17 00:00:00 2001 From: Salim Afiune Maya Date: Mon, 13 Apr 2020 09:05:14 -0600 Subject: [PATCH] feat: disallow extra arguments on sub-commands Signed-off-by: Salim Afiune Maya --- cli/cmd/api.go | 2 +- cli/cmd/configure.go | 3 ++- cli/cmd/integration.go | 12 ++++++++---- cli/cmd/version.go | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cli/cmd/api.go b/cli/cmd/api.go index aa161b183..83ece8f9c 100644 --- a/cli/cmd/api.go +++ b/cli/cmd/api.go @@ -64,7 +64,7 @@ func init() { ) } -func runApiCommand(cmd *cobra.Command, args []string) error { +func runApiCommand(_ *cobra.Command, args []string) error { switch args[0] { case "post", "patch": if apiData == "" { diff --git a/cli/cmd/configure.go b/cli/cmd/configure.go index 2423f7dbd..5e85b622d 100644 --- a/cli/cmd/configure.go +++ b/cli/cmd/configure.go @@ -44,7 +44,8 @@ var ( configureCmd = &cobra.Command{ Use: "configure", Short: "Set up your Lacework cli", - RunE: func(cmd *cobra.Command, args []string) error { + Args: cobra.NoArgs, + RunE: func(_ *cobra.Command, _ []string) error { var ( promptAccount = promptui.Prompt{ Label: "Account", diff --git a/cli/cmd/integration.go b/cli/cmd/integration.go index d56a854be..e2bc0325d 100644 --- a/cli/cmd/integration.go +++ b/cli/cmd/integration.go @@ -38,7 +38,8 @@ var ( integrationListCmd = &cobra.Command{ Use: "list", Short: "List all available external integrations", - RunE: func(cmd *cobra.Command, args []string) error { + Args: cobra.NoArgs, + RunE: func(_ *cobra.Command, _ []string) error { lacework, err := api.NewClient(cli.Account, api.WithLogLevel(cli.LogLevel), api.WithApiKeys(cli.KeyID, cli.Secret), @@ -62,7 +63,8 @@ var ( Use: "create", Hidden: true, Short: "Create an external integrations", - RunE: func(cmd *cobra.Command, args []string) error { + Args: cobra.NoArgs, + RunE: func(_ *cobra.Command, _ []string) error { return nil }, } @@ -72,7 +74,8 @@ var ( Use: "update", Hidden: true, Short: "Update an external integrations", - RunE: func(cmd *cobra.Command, args []string) error { + Args: cobra.NoArgs, + RunE: func(_ *cobra.Command, _ []string) error { return nil }, } @@ -82,7 +85,8 @@ var ( Use: "delete", Hidden: true, Short: "Delete an external integrations", - RunE: func(cmd *cobra.Command, args []string) error { + Args: cobra.NoArgs, + RunE: func(_ *cobra.Command, _ []string) error { return nil }, } diff --git a/cli/cmd/version.go b/cli/cmd/version.go index f106d90fd..70493e3aa 100644 --- a/cli/cmd/version.go +++ b/cli/cmd/version.go @@ -40,7 +40,8 @@ var ( versionCmd = &cobra.Command{ Use: "version", Short: "Print the Lacework cli version", - Run: func(cmd *cobra.Command, args []string) { + Args: cobra.NoArgs, + Run: func(_ *cobra.Command, _ []string) { fmt.Printf("lacework v%s (sha:%s) (time:%s)\n", Version, GitSHA, BuildTime) }, }