2022-08-21 15:03:53 +10:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func PromptContinue() bool {
|
2022-12-28 12:39:18 +11:00
|
|
|
ret := strings.ToLower(Prompt("Continue (y/n)"))
|
2022-08-21 15:03:53 +10:00
|
|
|
if ret == "y" || ret == "yes" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-09-21 15:00:10 +10:00
|
|
|
func PromptConfirm(question string) bool {
|
2022-12-28 12:39:18 +11:00
|
|
|
ret := Prompt(fmt.Sprintf("%s (y/n)?", question))
|
2022-09-21 15:00:10 +10:00
|
|
|
if ret == "y" || ret == "yes" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-09-22 11:58:21 +10:00
|
|
|
func SelectMenuItem(listMenu func()) string {
|
2022-08-21 19:33:02 +10:00
|
|
|
listMenu()
|
|
|
|
|
2022-09-21 15:00:10 +10:00
|
|
|
var option string
|
|
|
|
fmt.Scanf("%s", &option)
|
2022-08-21 19:33:02 +10:00
|
|
|
return option
|
|
|
|
}
|
|
|
|
|
2022-12-28 12:39:18 +11:00
|
|
|
func Prompt(question string) string {
|
2022-08-21 15:03:53 +10:00
|
|
|
fmt.Printf("%s %s :%s", colorYellow, question, colorReset)
|
|
|
|
var ret string
|
|
|
|
fmt.Scanf("%s", &ret)
|
|
|
|
return ret
|
|
|
|
}
|