本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/commandregistry.NewDependency函数的典型用法代码示例。如果您正苦于以下问题:Golang NewDependency函数的具体用法?Golang NewDependency怎么用?Golang NewDependency使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewDependency函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetService
func (cmd *CliRpcCmd) GetService(serviceInstance string, retVal *plugin_models.GetService_Model) error {
defer func() {
recover()
}()
deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout)
//set deps objs to be the one used by all other commands
//once all commands are converted, we can make fresh deps for each command run
deps.Config = cmd.cliConfig
deps.RepoLocator = cmd.repoLocator
deps.PluginModels.Service = retVal
cmd.terminalOutputSwitch.DisableTerminalOutput(true)
deps.UI = terminal.NewUI(os.Stdin, cmd.stdout, cmd.terminalOutputSwitch.(*terminal.TeePrinter), cmd.logger)
return cmd.newCmdRunner.Command([]string{"service", serviceInstance}, deps, true)
}
开发者ID:Reejoshi,项目名称:cli,代码行数:17,代码来源:cli_rpc_server.go
示例2: GetOrgUsers
func (cmd *CliRpcCmd) GetOrgUsers(args []string, retVal *[]plugin_models.GetOrgUsers_Model) error {
defer func() {
recover()
}()
deps := commandregistry.NewDependency(cmd.stdout, cmd.logger)
//set deps objs to be the one used by all other commands
//once all commands are converted, we can make fresh deps for each command run
deps.Config = cmd.cliConfig
deps.RepoLocator = cmd.repoLocator
deps.PluginModels.OrgUsers = retVal
cmd.terminalOutputSwitch.DisableTerminalOutput(true)
deps.UI = terminal.NewUI(os.Stdin, cmd.stdout, cmd.terminalOutputSwitch.(*terminal.TeePrinter), cmd.logger)
return cmd.newCmdRunner.Command(append([]string{"org-users"}, args...), deps, true)
}
开发者ID:jsloyer,项目名称:cli,代码行数:17,代码来源:cli_rpc_server.go
示例3: CallCoreCommand
func (cmd *CliRpcCmd) CallCoreCommand(args []string, retVal *bool) error {
defer func() {
recover()
}()
var err error
cmdRegistry := commandregistry.Commands
cmd.outputBucket = &bytes.Buffer{}
cmd.outputCapture.SetOutputBucket(cmd.outputBucket)
if cmdRegistry.CommandExists(args[0]) {
deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout)
//set deps objs to be the one used by all other commands
//once all commands are converted, we can make fresh deps for each command run
deps.Config = cmd.cliConfig
deps.RepoLocator = cmd.repoLocator
//set command ui's TeePrinter to be the one used by RpcService, for output to be captured
deps.UI = terminal.NewUI(os.Stdin, cmd.stdout, cmd.outputCapture.(*terminal.TeePrinter), cmd.logger)
err = cmd.newCmdRunner.Command(args, deps, false)
} else {
*retVal = false
return nil
}
if err != nil {
*retVal = false
return err
}
*retVal = true
return nil
}
开发者ID:Reejoshi,项目名称:cli,代码行数:36,代码来源:cli_rpc_server.go
示例4:
)
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.RepoLocator = deps.RepoLocator.SetAuthenticationRepository(authRepo)
deps.Config = configRepo
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("oauth-token").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
fakeLogger := new(tracefakes.FakePrinter)
authRepo = new(authenticationfakes.FakeRepository)
configRepo = testconfig.NewRepositoryWithDefaults()
requirementsFactory = new(requirementsfakes.FakeFactory)
deps = commandregistry.NewDependency(os.Stdout, fakeLogger)
})
runCommand := func() bool {
return testcmd.RunCLICommand("oauth-token", []string{}, requirementsFactory, updateCommandDependency, false, ui)
}
Describe("requirements", func() {
It("fails when the user is not logged in", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
Expect(runCommand()).ToNot(HavePassedRequirements())
})
})
Describe("when logged in", func() {
BeforeEach(func() {
开发者ID:jsloyer,项目名称:cli,代码行数:31,代码来源:oauth_token_test.go
示例5:
app.Routes = app1Routes
app.AppPorts = []int{8080, 9090}
app2 := models.Application{}
app2.Name = "Application-2"
app2.GUID = "Application-2-guid"
app2.State = "started"
app2.RunningInstances = 1
app2.InstanceCount = 2
app2.Memory = 256
app2.DiskQuota = 1024
app2.Routes = app2Routes
appSummaryRepo.GetSummariesInCurrentSpaceApps = []models.Application{app, app2}
deps = commandregistry.NewDependency(os.Stdout, new(tracefakes.FakePrinter))
})
runCommand := func(args ...string) bool {
return testcmd.RunCLICommand("apps", args, requirementsFactory, updateCommandDependency, false)
}
Describe("requirements", func() {
var cmd commandregistry.Command
var flagContext flags.FlagContext
BeforeEach(func() {
cmd = &application.ListApps{}
cmd.SetDependency(deps, false)
flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
开发者ID:yingkitw,项目名称:cli,代码行数:30,代码来源:apps_test.go
示例6: Main
func Main(traceEnv string, args []string) {
//handle `cf -v` for cf version
if len(args) == 2 && (args[1] == "-v" || args[1] == "--version") {
args[1] = "version"
}
//handles `cf`
if len(args) == 1 {
args = []string{args[0], "help"}
}
//handles `cf [COMMAND] -h ...`
//rearrange args to `cf help COMMAND` and let `command help` to print out usage
args = append([]string{args[0]}, handleHelp(args[1:])...)
newArgs, isVerbose := handleVerbose(args)
args = newArgs
errFunc := func(err error) {
if err != nil {
ui := terminal.NewUI(
os.Stdin,
Writer,
terminal.NewTeePrinter(Writer),
trace.NewLogger(Writer, isVerbose, traceEnv, ""),
)
ui.Failed(fmt.Sprintf("Config error: %s", err))
}
}
// Only used to get Trace, so our errorHandler doesn't matter, since it's not used
configPath, err := confighelpers.DefaultFilePath()
if err != nil {
errFunc(err)
}
config := coreconfig.NewRepositoryFromFilepath(configPath, errFunc)
defer config.Close()
traceConfigVal := config.Trace()
// Writer is assigned in writer_unix.go/writer_windows.go
traceLogger := trace.NewLogger(Writer, isVerbose, traceEnv, traceConfigVal)
deps := commandregistry.NewDependency(Writer, traceLogger, os.Getenv("CF_DIAL_TIMEOUT"))
defer handlePanics(args, deps.TeePrinter, deps.Logger)
defer deps.Config.Close()
//handle `cf --build`
if len(args) == 2 && (args[1] == "--build" || args[1] == "-b") {
deps.UI.Say(T("{{.CFName}} was built with Go version: {{.GoVersion}}",
map[string]interface{}{
"CFName": args[0],
"GoVersion": runtime.Version(),
}))
os.Exit(0)
}
warningProducers := []net.WarningProducer{}
for _, warningProducer := range deps.Gateways {
warningProducers = append(warningProducers, warningProducer)
}
warningsCollector := net.NewWarningsCollector(deps.UI, warningProducers...)
commandsloader.Load()
//run core command
cmdName := args[1]
cmd := cmdRegistry.FindCommand(cmdName)
if cmd != nil {
meta := cmd.MetaData()
flagContext := flags.NewFlagContext(meta.Flags)
flagContext.SkipFlagParsing(meta.SkipFlagParsing)
cmdArgs := args[2:]
err = flagContext.Parse(cmdArgs...)
if err != nil {
usage := cmdRegistry.CommandUsage(cmdName)
deps.UI.Failed(T("Incorrect Usage") + "\n\n" + err.Error() + "\n\n" + usage)
}
cmd = cmd.SetDependency(deps, false)
cmdRegistry.SetCommand(cmd)
requirementsFactory := requirements.NewFactory(deps.Config, deps.RepoLocator)
reqs := cmd.Requirements(requirementsFactory, flagContext)
for _, req := range reqs {
err = req.Execute()
if err != nil {
deps.UI.Failed(err.Error())
}
}
err = cmd.Execute(flagContext)
if err != nil {
ui := terminal.NewUI(os.Stdin, Writer, terminal.NewTeePrinter(Writer), traceLogger)
ui.Failed(err.Error())
}
//.........这里部分代码省略.........
开发者ID:Reejoshi,项目名称:cli,代码行数:101,代码来源:cmd.go
注:本文中的github.com/cloudfoundry/cli/cf/commandregistry.NewDependency函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论