go(utils): add promptMenu util function

pull/7/head
oscar 2022-08-21 21:33:02 +12:00
parent 4a5b954ad6
commit 5a6cd4ac16
2 changed files with 12 additions and 7 deletions

View File

@ -41,8 +41,10 @@ func InputPrint(message string) {
fmt.Println(colorYellow, message, colorReset) fmt.Println(colorYellow, message, colorReset)
} }
func MenuPrint() { func MenuPrint(question, menu string) {
InputPrint("Which repository or action do you want to operate:") if question != "" {
InputPrint(fmt.Sprintf("[%s]", question))
}
// menu := ` // menu := `
// 1. Build Portainer EE/CE All // 1. Build Portainer EE/CE All
@ -56,10 +58,5 @@ func MenuPrint() {
// 9. Cleanup Temporary Volume // 9. Cleanup Temporary Volume
// ` // `
menu := `1. Portainer EE Repository
2. Portainer CE Repository
3. Portainer Agent Repository
4. Others`
fmt.Println(colorCyan, menu, colorReset) fmt.Println(colorCyan, menu, colorReset)
} }

View File

@ -14,6 +14,14 @@ func PromptContinue() bool {
return false return false
} }
func PromptMenu(listMenu func()) int {
listMenu()
var option int
fmt.Scanf("%d", &option)
return option
}
func prompt(question string) string { func prompt(question string) string {
fmt.Printf("%s %s :%s", colorYellow, question, colorReset) fmt.Printf("%s %s :%s", colorYellow, question, colorReset)
var ret string var ret string