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

View File

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