kleinTodo/common/askUser.go

26 lines
419 B
Go
Raw Normal View History

2025-08-23 19:14:16 +02:00
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)
}