diff --git a/fly/integration/help_test.go b/fly/integration/help_test.go index 1c8b3928e..85cd77b6c 100644 --- a/fly/integration/help_test.go +++ b/fly/integration/help_test.go @@ -43,4 +43,17 @@ var _ = Describe("Fly CLI", func() { Expect(sess.Out).To(gbytes.Say("Available commands:")) }) }) + + Context("when invoking a subcommand with -h flag", func() { + It("prints help for the given subcommand", func() { + flyCmd := exec.Command(flyPath, "completion", "-h") + + sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter) + Expect(err).NotTo(HaveOccurred()) + + <-sess.Exited + Expect(sess.ExitCode()).To(Equal(0)) + Expect(sess.Out).To(gbytes.Say("completion command options")) + }) + }) }) diff --git a/fly/main.go b/fly/main.go index f0b18286c..2aceee8d2 100644 --- a/fly/main.go +++ b/fly/main.go @@ -68,7 +68,8 @@ func handleError(helpParser *flags.Parser, err error) { } else if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrCommandRequired { showHelp(helpParser) } else if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp { - showHelp(helpParser) + fmt.Println(err) + os.Exit(0) } else { fmt.Fprintf(ui.Stderr, "error: %s\n", err) }