From 8378fc667b24edef8eba9301d271321b69bcf526 Mon Sep 17 00:00:00 2001 From: James Cooper Date: Tue, 10 May 2022 11:27:47 -0700 Subject: [PATCH 1/2] Fix version subcommand. Do not print usage if run subcommand fails. --- cmd/godog/internal/cmd_run.go | 4 +++- cmd/godog/internal/cmd_version.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/godog/internal/cmd_run.go b/cmd/godog/internal/cmd_run.go index 52fde465..0c81f893 100644 --- a/cmd/godog/internal/cmd_run.go +++ b/cmd/godog/internal/cmd_run.go @@ -32,7 +32,8 @@ buildable go source.`, feature (*.feature) scenario at specific line (*.feature:10) If no feature arguments are supplied, godog will use "features/" by default.`, - RunE: runCmdRunFunc, + RunE: runCmdRunFunc, + SilenceUsage: true, } flags.BindRunCmdFlags("", runCmd.Flags(), &opts) @@ -41,6 +42,7 @@ buildable go source.`, } func runCmdRunFunc(cmd *cobra.Command, args []string) error { + osArgs := os.Args[1:] if len(osArgs) > 0 && osArgs[0] == "run" { diff --git a/cmd/godog/internal/cmd_version.go b/cmd/godog/internal/cmd_version.go index e0423f31..78fb8bcf 100644 --- a/cmd/godog/internal/cmd_version.go +++ b/cmd/godog/internal/cmd_version.go @@ -14,6 +14,7 @@ func CreateVersionCmd() cobra.Command { versionCmd := cobra.Command{ Use: "version", Short: "Show current version", + Run: versionCmdRunFunc, Version: godog.Version, } From ee1dbb69c2e36b598fcd0b9e38612e23c135351d Mon Sep 17 00:00:00 2001 From: James Cooper Date: Tue, 10 May 2022 11:33:25 -0700 Subject: [PATCH 2/2] Remove newline to clean up PR diff --- cmd/godog/internal/cmd_run.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/godog/internal/cmd_run.go b/cmd/godog/internal/cmd_run.go index 0c81f893..88137651 100644 --- a/cmd/godog/internal/cmd_run.go +++ b/cmd/godog/internal/cmd_run.go @@ -42,7 +42,6 @@ buildable go source.`, } func runCmdRunFunc(cmd *cobra.Command, args []string) error { - osArgs := os.Args[1:] if len(osArgs) > 0 && osArgs[0] == "run" {