remove showing help twice for incorrect commands (#3805)

* remove showing help twice for incorrect commands

* regression to check output happen only once
This commit is contained in:
Girish Ramnani
2020-08-24 17:03:05 +05:30
committed by GitHub
parent 865cfdd094
commit eaf7dded3e
2 changed files with 6 additions and 1 deletions

View File

@@ -272,6 +272,5 @@ func ShowHelp(cmd *cobra.Command, args []string) error {
return nil
}
_ = cmd.Help()
return fmt.Errorf("Invalid command - see available commands/subcommands above")
}

View File

@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
"time"
. "github.com/onsi/ginkgo"
@@ -46,6 +47,11 @@ var _ = Describe("odo generic", func() {
Expect(output).To(ContainSubstring("Subcommand not found, use one of the available commands"))
})
It("Fail with showing help only once for incorrect command", func() {
output := helper.CmdShouldFail("odo", "hello")
Expect(strings.Count(output, "odo [flags]")).Should(Equal(1))
})
})
Context("When executing catalog list without component directory", func() {