40 lines
627 B
Go
40 lines
627 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func PromptContinue() bool {
|
|
ret := strings.ToLower(Prompt("Continue (y/n)"))
|
|
if ret == "y" || ret == "yes" {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func PromptConfirm(question string) bool {
|
|
ret := Prompt(fmt.Sprintf("%s (y/n)?", question))
|
|
if ret == "y" || ret == "yes" {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func SelectMenuItem(listMenu func()) string {
|
|
listMenu()
|
|
|
|
var option string
|
|
fmt.Scanf("%s", &option)
|
|
return option
|
|
}
|
|
|
|
func Prompt(question string) string {
|
|
fmt.Printf("%s %s :%s", colorYellow, question, colorReset)
|
|
var ret string
|
|
fmt.Scanf("%s", &ret)
|
|
return ret
|
|
}
|