本文整理匯總了Golang中github.com/cloudfoundry-incubator/lattice/ltc/terminal.NewUI函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewUI函數的具體用法?Golang NewUI怎麽用?Golang NewUI使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewUI函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: MakeCliApp
func MakeCliApp(
diegoVersion string,
latticeVersion string,
ltcConfigRoot string,
exitHandler exit_handler.ExitHandler,
config *config.Config,
logger lager.Logger,
receptorClientCreator receptor_client.Creator,
targetVerifier target_verifier.TargetVerifier,
cliStdout io.Writer,
) *cli.App {
config.Load()
app := cli.NewApp()
app.Name = AppName
app.Author = latticeCliAuthor
app.Version = defaultVersion(diegoVersion, latticeVersion)
app.Usage = LtcUsage
app.Email = "[email protected]"
ui := terminal.NewUI(os.Stdin, cliStdout, password_reader.NewPasswordReader(exitHandler))
app.Writer = ui
app.Before = func(context *cli.Context) error {
args := context.Args()
command := app.Command(args.First())
if command == nil {
return nil
}
if _, ok := nonTargetVerifiedCommandNames[command.Name]; ok || len(args) == 0 {
return nil
}
if receptorUp, authorized, err := targetVerifier.VerifyTarget(config.Receptor()); !receptorUp {
ui.SayLine(fmt.Sprintf("Error connecting to the receptor. Make sure your lattice target is set, and that lattice is up and running.\n\tUnderlying error: %s", err.Error()))
return err
} else if !authorized {
ui.SayLine("Could not authenticate with the receptor. Please run ltc target with the correct credentials.")
return errors.New("Could not authenticate with the receptor.")
}
return nil
}
app.Action = defaultAction
app.CommandNotFound = func(c *cli.Context, command string) {
ui.SayLine(fmt.Sprintf(unknownCommand, command))
exitHandler.Exit(1)
}
app.Commands = cliCommands(ltcConfigRoot, exitHandler, config, logger, receptorClientCreator, targetVerifier, ui)
return app
}
示例2:
outputBuffer *gbytes.Buffer
terminalUI terminal.UI
domain string = "192.168.11.11.xip.io"
fakeClock *fakeclock.FakeClock
fakeDockerMetadataFetcher *fake_docker_metadata_fetcher.FakeDockerMetadataFetcher
appRunnerCommandFactoryConfig command_factory.DockerRunnerCommandFactoryConfig
logger lager.Logger
fakeTailedLogsOutputter *fake_tailed_logs_outputter.FakeTailedLogsOutputter
fakeExitHandler *fake_exit_handler.FakeExitHandler
)
BeforeEach(func() {
fakeAppRunner = &fake_app_runner.FakeAppRunner{}
fakeAppExaminer = &fake_app_examiner.FakeAppExaminer{}
outputBuffer = gbytes.NewBuffer()
terminalUI = terminal.NewUI(nil, outputBuffer, nil)
fakeDockerMetadataFetcher = &fake_docker_metadata_fetcher.FakeDockerMetadataFetcher{}
fakeClock = fakeclock.NewFakeClock(time.Now())
logger = lager.NewLogger("ltc-test")
fakeTailedLogsOutputter = fake_tailed_logs_outputter.NewFakeTailedLogsOutputter()
fakeExitHandler = &fake_exit_handler.FakeExitHandler{}
})
Describe("CreateAppCommand", func() {
var createCommand cli.Command
BeforeEach(func() {
env := []string{"SHELL=/bin/bash", "COLOR=Blue"}
appRunnerCommandFactoryConfig = command_factory.DockerRunnerCommandFactoryConfig{
AppRunner: fakeAppRunner,
AppExaminer: fakeAppExaminer,
示例3:
fakeDropletRunner = &fake_droplet_runner.FakeDropletRunner{}
fakeExitHandler = &fake_exit_handler.FakeExitHandler{}
fakeTailedLogsOutputter = fake_tailed_logs_outputter.NewFakeTailedLogsOutputter()
fakeClock = fakeclock.NewFakeClock(time.Now())
fakeAppExaminer = &fake_app_examiner.FakeAppExaminer{}
fakeTaskExaminer = &fake_task_examiner.FakeTaskExaminer{}
fakeCFIgnore = &fake_cf_ignore.FakeCFIgnore{}
fakeZipper = &fake_zipper.FakeZipper{}
fakeBlobStoreVerifier = &fake_blob_store_verifier.FakeBlobStoreVerifier{}
config = config_package.New(nil)
outputBuffer = gbytes.NewBuffer()
appRunnerCommandFactory = app_runner_command_factory.AppRunnerCommandFactory{
AppRunner: &fake_app_runner.FakeAppRunner{},
AppExaminer: fakeAppExaminer,
UI: terminal.NewUI(nil, outputBuffer, nil),
ExitHandler: fakeExitHandler,
TailedLogsOutputter: fakeTailedLogsOutputter,
Clock: fakeClock,
Domain: "192.168.11.11.xip.io",
Env: []string{"SHELL=/bin/bash", "COLOR=Black", "AAAA=xyz"},
}
})
Describe("BuildDropletCommand", func() {
var buildDropletCommand cli.Command
BeforeEach(func() {
commandFactory := droplet_runner_command_factory.NewDropletRunnerCommandFactory(appRunnerCommandFactory, fakeBlobStoreVerifier, fakeTaskExaminer, fakeDropletRunner, fakeCFIgnore, fakeZipper, config)
buildDropletCommand = commandFactory.MakeBuildDropletCommand()
fakeBlobStoreVerifier.VerifyReturns(true, nil)
示例4:
var (
stdinReader *io.PipeReader
stdinWriter *io.PipeWriter
outputBuffer *gbytes.Buffer
terminalUI terminal.UI
config *config_package.Config
fakeTargetVerifier *fake_target_verifier.FakeTargetVerifier
fakeExitHandler *fake_exit_handler.FakeExitHandler
)
BeforeEach(func() {
stdinReader, stdinWriter = io.Pipe()
outputBuffer = gbytes.NewBuffer()
fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
fakeExitHandler = new(fake_exit_handler.FakeExitHandler)
terminalUI = terminal.NewUI(stdinReader, outputBuffer, nil)
config = config_package.New(persister.NewMemPersister())
})
Describe("TargetBlobCommand", func() {
var targetBlobCommand cli.Command
BeforeEach(func() {
commandFactory := command_factory.NewConfigCommandFactory(config, terminalUI, fakeTargetVerifier, fakeExitHandler)
targetBlobCommand = commandFactory.MakeTargetBlobCommand()
})
Context("displaying the blob target", func() {
It("outputs the current target", func() {
config.SetBlobTarget("192.168.11.11", 8980, "datkeyyo", "supersecretJKJK", "bucket")
config.Save()
示例5:
outputBuffer *gbytes.Buffer
terminalUI terminal.UI
config *config_package.Config
configPersister persister.Persister
fakeTargetVerifier *fake_target_verifier.FakeTargetVerifier
fakeBlobStoreVerifier *fake_blob_store_verifier.FakeBlobStoreVerifier
fakeExitHandler *fake_exit_handler.FakeExitHandler
fakePasswordReader *fake_password_reader.FakePasswordReader
)
BeforeEach(func() {
stdinReader, stdinWriter = io.Pipe()
outputBuffer = gbytes.NewBuffer()
fakeExitHandler = &fake_exit_handler.FakeExitHandler{}
fakePasswordReader = &fake_password_reader.FakePasswordReader{}
terminalUI = terminal.NewUI(stdinReader, outputBuffer, fakePasswordReader)
fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
fakeBlobStoreVerifier = &fake_blob_store_verifier.FakeBlobStoreVerifier{}
configPersister = persister.NewMemPersister()
config = config_package.New(configPersister)
})
Describe("TargetCommand", func() {
var targetCommand cli.Command
verifyOldTargetStillSet := func() {
newConfig := config_package.New(configPersister)
Expect(newConfig.Load()).To(Succeed())
Expect(newConfig.Receptor()).To(Equal("http://olduser:[email protected]"))
}