예제 #1
0
func NewCliApp() *cli.App {
	config := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(ltcConfigRoot())))

	signalChan := make(chan os.Signal)
	signal.Notify(signalChan, os.Interrupt, syscall.SIGHUP, syscall.SIGTERM)
	exitHandler := exit_handler.New(signalChan, os.Exit)
	go exitHandler.Run()

	receptorClientCreator := receptor_client.ProxyAwareCreator{}

	return cli_app_factory.MakeCliApp(
		diegoVersion,
		latticeVersion,
		ltcConfigRoot(),
		exitHandler,
		config,
		logger(),
		receptorClientCreator,
		target_verifier.New(receptorClientCreator),
		os.Stdout,
	)
}
예제 #2
0
		memPersister := persister.NewMemPersister()
		outputBuffer = gbytes.NewBuffer()
		terminalUI = terminal.NewUI(nil, outputBuffer, nil)
		cliConfig = config.New(memPersister)
		latticeVersion, diegoVersion = "v0.2.Test", "0.12345.0"

		fakeReceptorClientCreator.CreateReceptorClientReturns(&fake_receptor.FakeClient{})
	})

	JustBeforeEach(func() {
		cliApp = cli_app_factory.MakeCliApp(
			diegoVersion,
			latticeVersion,
			"~/",
			fakeExitHandler,
			cliConfig,
			lager.NewLogger("test"),
			fakeReceptorClientCreator,
			fakeTargetVerifier,
			terminalUI,
		)
	})

	Describe("MakeCliApp", func() {
		It("makes an app", func() {
			Expect(cliApp).ToNot(BeNil())
			Expect(cliApp.Name).To(Equal("ltc"))
			Expect(cliApp.Author).To(Equal("Pivotal"))
			Expect(cliApp.Version).To(Equal("v0.2.Test (diego 0.12345.0)"))
			Expect(cliApp.Email).To(Equal("*****@*****.**"))
			Expect(cliApp.Usage).To(Equal(cli_app_factory.LtcUsage))
예제 #3
0
	subCommandTemplate := `NAME:
   {{.Name}} - {{.Usage}}
USAGE:
   {{.Name}} command{{if .Flags}} [command options]{{end}} [arguments...]
`
	BeforeEach(func() {
		outputBuffer = gbytes.NewBuffer()

		fakeReceptorClientCreator = &fake_receptor_client_creator.FakeCreator{}

		cliApp = cli_app_factory.MakeCliApp(
			"",
			"",
			"~/",
			nil,
			config.New(persister.NewMemPersister()),
			nil,
			fakeReceptorClientCreator,
			nil,
			terminal.NewUI(nil, outputBuffer, nil),
		)
	})

	Describe("ShowHelp", func() {

		It("shows help for all commands", func() {
			Expect(cliApp.Commands).NotTo(BeEmpty())

			cli_app_factory.ShowHelp(outputBuffer, dummyTemplate, cliApp)

			outputBytes, err := ioutil.ReadAll(outputBuffer)