Skip to content

Commit f67ca9a

Browse files
authored
feat: disallow extra arguments on sub-commands (#48)
Signed-off-by: Salim Afiune Maya <[email protected]>
1 parent f334fda commit f67ca9a

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

cli/cmd/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func init() {
6464
)
6565
}
6666

67-
func runApiCommand(cmd *cobra.Command, args []string) error {
67+
func runApiCommand(_ *cobra.Command, args []string) error {
6868
switch args[0] {
6969
case "post", "patch":
7070
if apiData == "" {

cli/cmd/configure.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ var (
4444
configureCmd = &cobra.Command{
4545
Use: "configure",
4646
Short: "Set up your Lacework cli",
47-
RunE: func(cmd *cobra.Command, args []string) error {
47+
Args: cobra.NoArgs,
48+
RunE: func(_ *cobra.Command, _ []string) error {
4849
var (
4950
promptAccount = promptui.Prompt{
5051
Label: "Account",

cli/cmd/integration.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ var (
3838
integrationListCmd = &cobra.Command{
3939
Use: "list",
4040
Short: "List all available external integrations",
41-
RunE: func(cmd *cobra.Command, args []string) error {
41+
Args: cobra.NoArgs,
42+
RunE: func(_ *cobra.Command, _ []string) error {
4243
lacework, err := api.NewClient(cli.Account,
4344
api.WithLogLevel(cli.LogLevel),
4445
api.WithApiKeys(cli.KeyID, cli.Secret),
@@ -62,7 +63,8 @@ var (
6263
Use: "create",
6364
Hidden: true,
6465
Short: "Create an external integrations",
65-
RunE: func(cmd *cobra.Command, args []string) error {
66+
Args: cobra.NoArgs,
67+
RunE: func(_ *cobra.Command, _ []string) error {
6668
return nil
6769
},
6870
}
@@ -72,7 +74,8 @@ var (
7274
Use: "update",
7375
Hidden: true,
7476
Short: "Update an external integrations",
75-
RunE: func(cmd *cobra.Command, args []string) error {
77+
Args: cobra.NoArgs,
78+
RunE: func(_ *cobra.Command, _ []string) error {
7679
return nil
7780
},
7881
}
@@ -82,7 +85,8 @@ var (
8285
Use: "delete",
8386
Hidden: true,
8487
Short: "Delete an external integrations",
85-
RunE: func(cmd *cobra.Command, args []string) error {
88+
Args: cobra.NoArgs,
89+
RunE: func(_ *cobra.Command, _ []string) error {
8690
return nil
8791
},
8892
}

cli/cmd/version.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ var (
4040
versionCmd = &cobra.Command{
4141
Use: "version",
4242
Short: "Print the Lacework cli version",
43-
Run: func(cmd *cobra.Command, args []string) {
43+
Args: cobra.NoArgs,
44+
Run: func(_ *cobra.Command, _ []string) {
4445
fmt.Printf("lacework v%s (sha:%s) (time:%s)\n", Version, GitSHA, BuildTime)
4546
},
4647
}

0 commit comments

Comments
 (0)