Example #1
0
File: apps.go Project: KaiYoung/cli
func coloredState(state string) (colored string) {
	switch state {
	case "started":
		colored = term.Green("running")
	case "stopped":
		colored = term.Yellow("stopped")
	default:
		colored = term.Red(state)
	}

	return
}
Example #2
0
func (l Login) chooseSpace(spaces []cf.Space) (space cf.Space) {
	for i, space := range spaces {
		l.ui.Say("%s: %s", term.Green(strconv.Itoa(i+1)), space.Name)
	}

	index, err := strconv.Atoi(l.ui.Ask("Space%s", term.Cyan(">")))

	if err != nil || index > len(spaces) {
		l.ui.Failed("Invalid number", err)
		return l.chooseSpace(spaces)
	}

	return spaces[index-1]
}
Example #3
0
func (l Login) chooseOrg(orgs []cf.Organization) (org cf.Organization) {
	for i, org := range orgs {
		l.ui.Say("%s: %s", term.Green(strconv.Itoa(i+1)), org.Name)
	}

	index, err := strconv.Atoi(l.ui.Ask("Organization%s", term.Cyan(">")))

	if err != nil || index > len(orgs) {
		l.ui.Failed("Invalid number", err)
		return l.chooseOrg(orgs)
	}

	return orgs[index-1]
}