本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/terminal.NewUI函数的典型用法代码示例。如果您正苦于以下问题:Golang NewUI函数的具体用法?Golang NewUI怎么用?Golang NewUI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewUI函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Run
func (c *NozzlerCmd) Run(cliConnection plugin.CliConnection, args []string) {
var debug bool
if args[0] != "nozzle" {
return
}
c.ui = terminal.NewUI(os.Stdin, terminal.NewTeePrinter())
fc := flags.NewFlagContext(setupFlags())
err := fc.Parse(args[1:]...)
if err != nil {
c.ui.Failed(err.Error())
}
if fc.IsSet("debug") {
debug = fc.Bool("debug")
}
dopplerEndpoint, err := cliConnection.DopplerEndpoint()
if err != nil {
c.ui.Failed(err.Error())
}
authToken, err := cliConnection.AccessToken()
if err != nil {
c.ui.Failed(err.Error())
}
client := firehose.NewClient(authToken, dopplerEndpoint, debug, c.ui)
client.Start()
}
开发者ID:jtuchscherer,项目名称:nozzle-plugin,代码行数:29,代码来源:main.go
示例2: NewListAppsCommand
func NewListAppsCommand(cliConnection api.Connection, orgName string, spaceName string, runtime ui.Runtime) (ui.ListAppsCommand, error) {
username, err := cliConnection.Username()
if err != nil {
return ui.ListAppsCommand{}, err
}
if spaceName != "" {
space, err := cliConnection.GetSpace(spaceName)
if err != nil || space.Guid == "" {
return ui.ListAppsCommand{}, err
}
orgName = space.Organization.Name
}
traceEnv := os.Getenv("CF_TRACE")
traceLogger := trace.NewLogger(false, traceEnv, "")
tUI := terminal.NewUI(os.Stdin, terminal.NewTeePrinter(), traceLogger)
cmd := ui.ListAppsCommand{
Username: username,
Organization: orgName,
Space: spaceName,
UI: tUI,
Runtime: runtime,
}
return cmd, nil
}
开发者ID:cloudfoundry-incubator,项目名称:Diego-Enabler,代码行数:27,代码来源:helper.go
示例3: newRequestForFile
func newRequestForFile(method, fullUrl string, body *os.File) (req *Request, apiErr error) {
ui := terminal.NewUI(os.Stdin, &cliutil.NonPrinter{})
progressReader := net.NewProgressReader(body, ui, 5*time.Second)
progressReader.Seek(0, 0)
fileStats, err := body.Stat()
if err != nil {
apiErr = fmt.Errorf("%s: %s", "Error getting file info", err.Error())
return
}
request, err := http.NewRequest(method, fullUrl, progressReader)
if err != nil {
apiErr = fmt.Errorf("%s: %s", "Error building request", err.Error())
return
}
fileSize := fileStats.Size()
progressReader.SetTotalSize(fileSize)
request.ContentLength = fileSize
if err != nil {
apiErr = fmt.Errorf("%s: %s", "Error building request", err.Error())
return
}
return newRequest(request, progressReader)
}
开发者ID:glyn,项目名称:bloblets,代码行数:28,代码来源:abclient.go
示例4: setupDependencies
func setupDependencies() (deps *cliDependencies) {
deps = new(cliDependencies)
deps.termUI = terminal.NewUI(os.Stdin)
deps.manifestRepo = manifest.NewManifestDiskRepository()
deps.configRepo = configuration.NewRepositoryFromFilepath(configuration.DefaultFilePath(), func(err error) {
if err != nil {
deps.termUI.Failed(fmt.Sprintf("Config error: %s", err))
}
})
i18n.T = i18n.Init(deps.configRepo)
terminal.UserAskedForColors = deps.configRepo.ColorEnabled()
terminal.InitColorSupport()
if os.Getenv("CF_TRACE") != "" {
trace.Logger = trace.NewLogger(os.Getenv("CF_TRACE"))
} else {
trace.Logger = trace.NewLogger(deps.configRepo.Trace())
}
deps.gateways = map[string]net.Gateway{
"auth": net.NewUAAGateway(deps.configRepo),
"cloud-controller": net.NewCloudControllerGateway(deps.configRepo, time.Now),
"uaa": net.NewUAAGateway(deps.configRepo),
}
deps.apiRepoLocator = api.NewRepositoryLocator(deps.configRepo, deps.gateways)
return
}
开发者ID:matanzit,项目名称:cli,代码行数:33,代码来源:main.go
示例5: Run
func (s *FirehoseStatsCmd) Run(cliConnection plugin.CliConnection, args []string) {
if args[0] != "firehose-stats" {
return
}
s.cfUI = terminal.NewUI(os.Stdin, terminal.NewTeePrinter())
dopplerEndpoint, err := cliConnection.DopplerEndpoint()
if err != nil {
s.cfUI.Failed(err.Error())
}
authToken, err := cliConnection.AccessToken()
if err != nil {
s.cfUI.Failed(err.Error())
}
firehoseChan := make(chan *events.Envelope)
client := firehose.NewClient(authToken, dopplerEndpoint, s.cfUI, firehoseChan)
client.Start()
statsUI := stats.New(client, s.cfUI, cliConnection)
statsUI.Start()
}
开发者ID:wfernandes,项目名称:firehose-stats,代码行数:25,代码来源:main.go
示例6: CallCoreCommand
func (cmd *CliRpcCmd) CallCoreCommand(args []string, retVal *bool) error {
defer func() {
recover()
}()
var err error
cmdRegistry := command_registry.Commands
cmd.outputBucket = &[]string{}
cmd.outputCapture.SetOutputBucket(cmd.outputBucket)
if cmdRegistry.CommandExists(args[0]) {
deps := command_registry.NewDependency()
//set deps objs to be the one used by all other codegangsta commands
//once all commands are converted, we can make fresh deps for each command run
deps.Config = cmd.cliConfig
deps.RepoLocator = cmd.repoLocator
deps.Ui = terminal.NewUI(os.Stdin, cmd.outputCapture.(*terminal.TeePrinter))
err = cmd.newCmdRunner.Command(args, deps, false)
} else {
//call codegangsta command
err = cmd.coreCommandRunner.Run(append([]string{"CF_NAME"}, args...))
}
if err != nil {
*retVal = false
return err
}
*retVal = true
return nil
}
开发者ID:tools-alexuser01,项目名称:cli,代码行数:34,代码来源:cli_rpc_server.go
示例7: NewDependency
func NewDependency() Dependency {
deps := Dependency{}
deps.TeePrinter = terminal.NewTeePrinter()
deps.Ui = terminal.NewUI(os.Stdin, deps.TeePrinter)
deps.ManifestRepo = manifest.NewManifestDiskRepository()
errorHandler := func(err error) {
if err != nil {
deps.Ui.Failed(fmt.Sprintf("Config error: %s", err))
}
}
deps.Config = core_config.NewRepositoryFromFilepath(config_helpers.DefaultFilePath(), errorHandler)
deps.PluginConfig = plugin_config.NewPluginConfig(errorHandler)
deps.Detector = &detection.JibberJabberDetector{}
terminal.UserAskedForColors = deps.Config.ColorEnabled()
terminal.InitColorSupport()
if os.Getenv("CF_TRACE") != "" {
trace.Logger = trace.NewLogger(os.Getenv("CF_TRACE"))
} else {
trace.Logger = trace.NewLogger(deps.Config.Trace())
}
deps.Gateways = map[string]net.Gateway{
"auth": net.NewUAAGateway(deps.Config, deps.Ui),
"cloud-controller": net.NewCloudControllerGateway(deps.Config, time.Now, deps.Ui),
"uaa": net.NewUAAGateway(deps.Config, deps.Ui),
}
deps.RepoLocator = api.NewRepositoryLocator(deps.Config, deps.Gateways)
deps.PluginModels = &pluginModels{Application: nil}
return deps
}
开发者ID:tools-alexuser01,项目名称:cli,代码行数:35,代码来源:dependency.go
示例8: Run
func (c *NozzlerCmd) Run(cliConnection plugin.CliConnection, args []string) {
var options *firehose.ClientOptions
traceLogger := trace.NewLogger(os.Stdout, true, os.Getenv("CF_TRACE"), "")
c.ui = terminal.NewUI(os.Stdin, os.Stdout, terminal.NewTeePrinter(os.Stdout), traceLogger)
switch args[0] {
case "nozzle":
options = c.buildClientOptions(args)
case "app-nozzle":
options = c.buildClientOptions(args)
appModel, err := cliConnection.GetApp(args[1])
if err != nil {
c.ui.Warn(err.Error())
return
}
options.AppGUID = appModel.Guid
default:
return
}
dopplerEndpoint, err := cliConnection.DopplerEndpoint()
if err != nil {
c.ui.Failed(err.Error())
}
authToken, err := cliConnection.AccessToken()
if err != nil {
c.ui.Failed(err.Error())
}
client := firehose.NewClient(authToken, dopplerEndpoint, options, c.ui)
client.Start()
}
开发者ID:cloudfoundry,项目名称:firehose-plugin,代码行数:35,代码来源:main.go
示例9: WildcardCommandApps
func (cmd *Wildcard) WildcardCommandApps(cliConnection plugin.CliConnection, args []string) {
InitializeCliDependencies()
defer panic.HandlePanics()
cmd.getMatchedApps(cliConnection, args)
cmd.ui = terminal.NewUI(os.Stdin, terminal.NewTeePrinter())
table := terminal.NewTable(cmd.ui, []string{T("name"), T("requested state"), T("instances"), T("memory"), T("disk"), T("urls")})
for _, app := range cmd.matchedApps {
var urls []string
for _, route := range app.Routes {
if route.Host == "" {
urls = append(urls, route.Domain.Name)
}
urls = append(urls, fmt.Sprintf("%s.%s", route.Host, route.Domain.Name))
}
table.Add(
app.Name,
app.State,
strconv.Itoa(app.RunningInstances),
formatters.ByteSize(app.Memory*formatters.MEGABYTE),
formatters.ByteSize(app.DiskQuota*formatters.MEGABYTE),
strings.Join(urls, ", "),
)
}
table.Print()
}
开发者ID:guidowb,项目名称:Wildcard_Plugin,代码行数:25,代码来源:wildcard_plugin.go
示例10: handlePanics
func handlePanics() {
panic_printer.UI = terminal.NewUI(os.Stdin)
commandArgs := strings.Join(os.Args, " ")
stackTrace := generateBacktrace()
err := recover()
panic_printer.DisplayCrashDialog(err, commandArgs, stackTrace)
if err != nil {
os.Exit(1)
}
}
开发者ID:matanzit,项目名称:cli,代码行数:13,代码来源:main.go
示例11: handlePanics
func handlePanics(args []string, printer terminal.Printer, logger trace.Printer) {
panicPrinter := panicprinter.NewPanicPrinter(terminal.NewUI(os.Stdin, Writer, printer, logger))
commandArgs := strings.Join(args, " ")
stackTrace := generateBacktrace()
err := recover()
panicPrinter.DisplayCrashDialog(err, commandArgs, stackTrace)
if err != nil {
os.Exit(1)
}
}
开发者ID:Reejoshi,项目名称:cli,代码行数:13,代码来源:cmd.go
示例12: Run
/*
* This function must be implemented by any plugin because it is part of the
* plugin interface defined by the core CLI.
*
* Run(....) is the entry point when the core CLI is invoking a command defined
* by a plugin. The first parameter, plugin.CliConnection, is a struct that can
* be used to invoke cli commands. The second paramter, args, is a slice of
* strings. args[0] will be the name of the command, and will be followed by
* any additional arguments a cli user typed in.
*
* Any error handling should be handled with the plugin itself (this means printing
* user facing errors). The CLI will exit 0 if the plugin exits 0 and will exit
* 1 should the plugin exits nonzero.
*/
func (c *DoctorPlugin) Run(cliConnection plugin.CliConnection, args []string) {
fmt.Printf("\n\n")
var triageApps []string
var triageRoutes []string
var triageServices []string
c.ui = terminal.NewUI(os.Stdin, terminal.NewTeePrinter())
c.ui.Say(terminal.WarningColor("doctor: time to triage cloudfoundry"))
fmt.Printf("\n")
c.CFMainChecks(cliConnection)
listOfRunningApps := c.AppsStateRunning(cliConnection)
listOfStoppedApps := c.AppsStateStopped(cliConnection)
triageApps = c.CheckUpApps(cliConnection, triageApps, listOfRunningApps, listOfStoppedApps)
triageRoutes = c.CheckUpRoutes(cliConnection, triageRoutes)
triageServices = c.CheckUpServices(cliConnection, triageServices)
if len(triageApps) == 0 && len(triageRoutes) == 0 && len(triageServices) == 0 {
c.ui.Say(terminal.SuccessColor("doctor: Everything looks OK!"))
return
}
// doctor run results
if len(triageApps) > 0 {
c.ui.Say(terminal.WarningColor("Detected triage points for apps: "))
for _, v := range triageApps {
c.ui.Say(terminal.LogStderrColor(strings.Split(v, "___")[0]+" <---> ") + terminal.LogStderrColor(strings.Split(v, "___")[1]))
}
}
c.ui.Say(" ")
if len(triageRoutes) > 0 {
c.ui.Say(terminal.WarningColor("Following routes do not have any app bound to them:"))
for _, y := range triageRoutes {
c.ui.Say(terminal.LogStderrColor(y))
}
}
fmt.Printf("\n")
if len(triageServices) > 0 {
c.ui.Say(terminal.WarningColor("Following services do not have any app bound to them:"))
for _, y := range triageServices {
c.ui.Say(terminal.LogStderrColor(y))
}
}
}
开发者ID:afeld,项目名称:cf-doctor-plugin,代码行数:62,代码来源:main.go
示例13: New
func New(ccTarget string, uaaTarget string, username string, password string) (*CFServices, error) {
cfs := CFServices{
CCTarget: ccTarget,
UAATarget: uaaTarget,
Username: username,
Password: password,
SessionID: uuid.New(),
}
cfs.gateways = make(map[string]net.Gateway)
cfs.configFilePath = strings.Replace(config_helpers.DefaultFilePath(), ".json", "."+cfs.SessionID+".json", -1)
cfs.config = core_config.NewRepositoryFromFilepath(cfs.configFilePath,
func(err error) {
if err != nil {
fmt.Printf("Config error: %s", err)
}
})
cfs.config.SetApiEndpoint(ccTarget)
cfs.config.SetAuthenticationEndpoint(uaaTarget)
cfs.config.SetUaaEndpoint(uaaTarget)
cfs.config.SetSSLDisabled(true)
cfs.teePrinter = terminal.NewTeePrinter()
cfs.termUI = terminal.NewUI(os.Stdin, cfs.teePrinter)
cfs.detector = &detection.JibberJabberDetector{}
T = Init(cfs.config, cfs.detector)
terminal.UserAskedForColors = cfs.config.ColorEnabled()
terminal.InitColorSupport()
cfs.gateways["cloud-controller"] = net.NewCloudControllerGateway(cfs.config, time.Now, cfs.termUI)
cfs.gateways["auth"] = net.NewUAAGateway(cfs.config, cfs.termUI)
cfs.gateways["uaa"] = net.NewUAAGateway(cfs.config, cfs.termUI)
cfs.authRepo = authentication.NewUAAAuthenticationRepository(cfs.gateways["uaa"], cfs.config)
cfs.Organizations = organizations.NewCloudControllerOrganizationRepository(cfs.config, cfs.gateways["cloud-controller"])
cfs.Spaces = spaces.NewCloudControllerSpaceRepository(cfs.config, cfs.gateways["cloud-controller"])
cfs.Services = api.NewCloudControllerServiceRepository(cfs.config, cfs.gateways["cloud-controller"])
cfs.Plans = api.NewCloudControllerServicePlanRepository(cfs.config, cfs.gateways["cloud-controller"])
err := cfs.authRepo.Authenticate(map[string]string{
"username": username,
"password": password,
})
return &cfs, err
}
开发者ID:jrbudnack,项目名称:cf-sql-broker,代码行数:47,代码来源:cfservices.go
示例14: GetOrg
func (cmd *CliRpcCmd) GetOrg(orgName string, retVal *plugin_models.GetOrg_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.Organization = retVal
cmd.terminalOutputSwitch.DisableTerminalOutput(true)
deps.UI = terminal.NewUI(os.Stdin, cmd.stdout, cmd.terminalOutputSwitch.(*terminal.TeePrinter), cmd.logger)
return cmd.newCmdRunner.Command([]string{"org", orgName}, deps, true)
}
开发者ID:Reejoshi,项目名称:cli,代码行数:17,代码来源:cli_rpc_server.go
示例15: GetSpaceUsers
func (cmd *CliRpcCmd) GetSpaceUsers(args []string, retVal *[]plugin_models.User) error {
defer func() {
recover()
}()
deps := command_registry.NewDependency()
//set deps objs to be the one used by all other codegangsta 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.Users = retVal
cmd.terminalOutputSwitch.DisableTerminalOutput(true)
deps.Ui = terminal.NewUI(os.Stdin, cmd.terminalOutputSwitch.(*terminal.TeePrinter))
return cmd.newCmdRunner.Command(append([]string{"space-users"}, args...), deps, true)
}
开发者ID:tools-alexuser01,项目名称:cli,代码行数:17,代码来源:cli_rpc_server.go
示例16: GetService
func (cmd *CliRpcCmd) GetService(serviceInstance string, retVal *plugin_models.GetService_Model) error {
defer func() {
recover()
}()
deps := command_registry.NewDependency(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.Service = retVal
cmd.terminalOutputSwitch.DisableTerminalOutput(true)
deps.Ui = terminal.NewUI(os.Stdin, cmd.terminalOutputSwitch.(*terminal.TeePrinter), cmd.logger)
return cmd.newCmdRunner.Command([]string{"service", serviceInstance}, deps, true)
}
开发者ID:cloudfoundry-incubator,项目名称:Diego-Enabler,代码行数:17,代码来源:cli_rpc_server.go
示例17: Run
/*
* This function must be implemented by any plugin because it is part of the
* plugin interface defined by the core CLI.
*
* Run(....) is the entry point when the core CLI is invoking a command defined
* by a plugin. The first parameter, plugin.CliConnection, is a struct that can
* be used to invoke cli commands. The second paramter, args, is a slice of
* strings. args[0] will be the name of the command, and will be followed by
* any additional arguments a cli user typed in.
*
* Any error handling should be handled with the plugin itself (this means printing
* user facing errors). The CLI will exit 0 if the plugin exits 0 and will exit
* 1 should the plugin exits nonzero.
*/
func (c *FastPushPlugin) Run(cliConnection plugin.CliConnection, args []string) {
// Ensure that the user called the command fast-push
// alias fp is auto mapped
var dryRun bool
c.ui = terminal.NewUI(os.Stdin, terminal.NewTeePrinter())
cliLogged, err := cliConnection.IsLoggedIn()
if err != nil {
c.ui.Failed(err.Error())
}
if cliLogged == false {
panic("cannot perform fast-push without being logged in to CF")
}
if args[0] == "fast-push" || args[0] == "fp" {
if len(args) == 1 {
c.showUsage(args)
return
}
// set flag for dry run
fc := flags.New()
fc.NewBoolFlag("dry", "d", "bool dry run flag")
err := fc.Parse(args[1:]...)
if err != nil {
c.ui.Failed(err.Error())
}
// check if the user asked for a dry run or not
if fc.IsSet("dry") {
dryRun = fc.Bool("dry")
} else {
c.ui.Warn("warning: dry run not set, commencing fast push")
}
c.ui.Say("Running the fast-push command")
c.ui.Say("Target app: %s \n", args[1])
c.FastPush(cliConnection, args[1], dryRun)
} else if args[0] == "fast-push-status" || args[0] == "fps" {
c.FastPushStatus(cliConnection, args[1])
} else {
return
}
}
开发者ID:riccardomc,项目名称:cf-fastpush-plugin,代码行数:59,代码来源:main.go
示例18: setupDependencies
func setupDependencies() (deps *cliDependencies) {
deps = new(cliDependencies)
deps.teePrinter = terminal.NewTeePrinter()
deps.termUI = terminal.NewUI(os.Stdin, deps.teePrinter)
deps.manifestRepo = manifest.NewManifestDiskRepository()
errorHandler := func(err error) {
if err != nil {
deps.termUI.Failed(fmt.Sprintf("Config error: %s", err))
}
}
deps.configRepo = core_config.NewRepositoryFromFilepath(config_helpers.DefaultFilePath(), errorHandler)
deps.pluginConfig = plugin_config.NewPluginConfig(errorHandler)
deps.detector = &detection.JibberJabberDetector{}
T = Init(deps.configRepo, deps.detector)
terminal.UserAskedForColors = deps.configRepo.ColorEnabled()
terminal.InitColorSupport()
if os.Getenv("CF_TRACE") != "" {
trace.Logger = trace.NewLogger(os.Getenv("CF_TRACE"))
} else {
trace.Logger = trace.NewLogger(deps.configRepo.Trace())
}
deps.gateways = map[string]net.Gateway{
"auth": net.NewUAAGateway(deps.configRepo, deps.termUI),
"cloud-controller": net.NewCloudControllerGateway(deps.configRepo, time.Now, deps.termUI),
"uaa": net.NewUAAGateway(deps.configRepo, deps.termUI),
}
deps.apiRepoLocator = api.NewRepositoryLocator(deps.configRepo, deps.gateways)
return
}
开发者ID:raghulsid,项目名称:cli,代码行数:38,代码来源:main.go
示例19: CallCoreCommand
func (cmd *CliRpcCmd) CallCoreCommand(args []string, retVal *bool) error {
defer func() {
recover()
}()
var err error
cmdRegistry := command_registry.Commands
cmd.outputBucket = &[]string{}
cmd.outputCapture.SetOutputBucket(cmd.outputBucket)
if cmdRegistry.CommandExists(args[0]) {
deps := command_registry.NewDependency(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
//set command ui's TeePrinter to be the one used by RpcService, for output to be captured
deps.Ui = terminal.NewUI(os.Stdin, 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:cloudfoundry-incubator,项目名称:Diego-Enabler,代码行数:36,代码来源:cli_rpc_server.go
示例20: main
func main() {
plugin.Start(&watch.Plugin{
Session: &scp.Session{},
UI: terminal.NewUI(os.Stdin, terminal.NewTeePrinter()),
})
}
开发者ID:pivotal-cf,项目名称:cf-watch,代码行数:6,代码来源:main.go
注:本文中的github.com/cloudfoundry/cli/cf/terminal.NewUI函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论