Exemplo n.º 1
0
					flagSet := flag.NewFlagSet("flag_set", flag.ContinueOnError)
					flagSet.Parse([]string{"one_arg"})
					testContext := cli.NewContext(cliApp, flagSet, nil)

					cliApp.Action(testContext)

					Expect(outputBuffer).To(test_helpers.Say("ltc: 'one_arg' is not a registered command. See 'ltc help'"))
				})
			})
		})

		Describe("App.CommandNotFound", func() {
			It("prints unknown command message and exits nonzero", func() {
				testContext := cli.NewContext(cliApp, &flag.FlagSet{}, nil)

				cliApp.CommandNotFound(testContext, "do_it")

				Expect(outputBuffer).To(test_helpers.Say("ltc: 'do_it' is not a registered command. See 'ltc help'"))
				Expect(fakeExitHandler.ExitCalledWith).To(Equal([]int{1}))
			})
		})

		Describe("App.Before", func() {
			Context("when running the target command", func() {
				It("does not verify the current target", func() {
					cliConfig.SetTarget("my-lattice.example.com")
					Expect(cliConfig.Save()).To(Succeed())

					commandRan := false

					cliApp.Commands = []cli.Command{