本文整理汇总了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
}
开发者ID:datachand,项目名称:lattice,代码行数:52,代码来源:cli_app_factory.go
示例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,
开发者ID:rowhit,项目名称:lattice,代码行数:31,代码来源:docker_runner_command_factory_test.go
示例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)
开发者ID:SrinivasChilveri,项目名称:lattice,代码行数:31,代码来源:droplet_runner_command_factory_test.go
示例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()
开发者ID:se77en,项目名称:lattice,代码行数:31,代码来源:blob_config_command_factory_test.go
示例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]"))
}
开发者ID:SrinivasChilveri,项目名称:lattice,代码行数:31,代码来源:config_command_factory_test.go
注:本文中的github.com/cloudfoundry-incubator/lattice/ltc/terminal.NewUI函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论