26 lines
419 B
Go
26 lines
419 B
Go
package common
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func AskUserBool(question string) bool {
|
|
switch AskUserString(fmt.Sprintf("%s (Y/N): ", question)) {
|
|
case "y", "Y", "yes":
|
|
return true
|
|
case "n", "N", "no":
|
|
return false
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func AskUserString(question string) string {
|
|
fmt.Printf(question)
|
|
reader := bufio.NewReader(os.Stdin)
|
|
input, _, _ := reader.ReadLine()
|
|
return string(input)
|
|
}
|