Exemple #1
0
func selectTemplate() template.Template {
	templates := template.All()

	term.Section()
	term.Println("Choose a template for you app:")
	for i, template := range templates {
		term.Printf("  %d) %s\n", i+1, template.Label)
	}

	term.Section()
	for {
		selected := -1 + term.GetInt(fmt.Sprintf("Please select (1-%d)", len(templates)))
		if selected >= 0 && selected < len(templates) {
			return templates[selected]
		}
	}
}
Exemple #2
0
func selectApp() (account.App, error) {
	apps, _ := account.GetUserApps()
	selected := -1
	if len(apps) == 0 {
		term.Section()
		term.Println("You have not created any apps yet!")
		term.Println("Log in on https://appstax.com and create one before you proceed.")
	} else {
		term.Section()
		term.Println("Choose which app to configure:")
		for i, app := range apps {
			term.Printf("  %d) %s\n", i+1, app.AppName)
		}
		term.Section()
		for selected < 0 || selected >= len(apps) {
			selected = -1 + term.GetInt(fmt.Sprintf("Please select (1-%d)", len(apps)))
		}
	}
	return apps[selected], nil
}