Пример #1
0
func (c *browserUI) Failed(message string, args ...interface{}) {
	message = fmt.Sprintf(message, args...)

	if T == nil {
		c.Say(terminal.FailureColor("FAILED"))
		c.Say(message)

		trace.Logger.Print("FAILED")
		trace.Logger.Print(message)
		c.PanicQuietly()
	} else {
		c.Say(terminal.FailureColor(T("FAILED")))
		c.Say(message)

		trace.Logger.Print(T("FAILED"))
		trace.Logger.Print(message)
		c.PanicQuietly()
	}
}
func (req CCApiVersionRequirement) Execute() bool {
	versions := strings.Split(req.config.ApiVersion(), ".")

	if len(versions) != 3 {
		return true
	}

	majorStr := versions[0]
	major, err := strconv.Atoi(majorStr)
	if err != nil {
		return true
	}

	minorStr := versions[1]
	minor, err := strconv.Atoi(minorStr)
	if err != nil {
		return true
	}

	patchStr := versions[2]
	patch, err := strconv.Atoi(patchStr)
	if err != nil {
		return true
	}

	if major > req.major {
		return true
	} else if major < req.major {
		return false
	}

	if minor > req.minor {
		return true
	} else if minor < req.minor {
		return false
	}

	if patch >= req.patch {
		return true
	}

	req.ui.Say(terminal.FailureColor(T("FAILED")))
	req.ui.Say(T("Current CF CLI version {{.Version}}", map[string]interface{}{"Version": cf.Version}))
	req.ui.Say(T("Current CF API version {{.ApiVersion}}", map[string]interface{}{"ApiVersion": req.config.ApiVersion()}))
	req.ui.Say(T("To use the {{.CommandName}} feature, you need to upgrade the CF API to at least {{.MinApiVersionMajor}}.{{.MinApiVersionMinor}}.{{.MinApiVersionPatch}}",
		map[string]interface{}{
			"CommandName":        req.commandName,
			"MinApiVersionMajor": req.major,
			"MinApiVersionMinor": req.minor,
			"MinApiVersionPatch": req.patch,
		}))

	return false
}
Пример #3
0
func (c *browserUI) FailWithUsage(context *cli.Context) {
	c.Say(terminal.FailureColor(T("FAILED")))
	c.Say(T("Incorrect Usage.\n"))
	cli.ShowCommandHelp(context, context.Command.Name)
	c.Say("")
}