Skip to content

Commit

Permalink
fix: command argument count validations (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Apr 8, 2024
1 parent 81a8375 commit 3c17146
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func newAddCmd(opts *lefthook.Options) *cobra.Command {
Long: addDoc,
Example: "lefthook add pre-commit",
ValidArgsFunction: addHookCompletions,
Args: cobra.MinimumNArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(_cmd *cobra.Command, hooks []string) error {
args.Hook = hooks[0]
return lefthook.Add(opts, &args)
Expand Down
1 change: 1 addition & 0 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func newDumpCmd(opts *lefthook.Options) *cobra.Command {
Short: "Prints config merged from all extensions (in YAML format by default)",
Example: "lefthook dump",
ValidArgsFunction: cobra.NoFileCompletions,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
lefthook.Dump(opts, dumpArgs)
},
Expand Down
1 change: 1 addition & 0 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func newInstallCmd(opts *lefthook.Options) *cobra.Command {
Use: "install",
Short: "Write basic configuration file in your project repository. Or initialize existed config",
ValidArgsFunction: cobra.NoFileCompletions,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _args []string) error {
return lefthook.Install(opts, force)
},
Expand Down
1 change: 1 addition & 0 deletions cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func newUninstallCmd(opts *lefthook.Options) *cobra.Command {
Use: "uninstall",
Short: "Revert install command",
ValidArgsFunction: cobra.NoFileCompletions,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _args []string) error {
return lefthook.Uninstall(opts, &args)
},
Expand Down
1 change: 1 addition & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func newVersionCmd(_opts *lefthook.Options) *cobra.Command {
Use: "version",
Short: "Show lefthook version",
ValidArgsFunction: cobra.NoFileCompletions,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
log.Println(version.Version(verbose))
},
Expand Down

0 comments on commit 3c17146

Please sign in to comment.