39 lines
632 B
Go
39 lines
632 B
Go
package cli
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"sevenkeys/logic"
|
|
"strings"
|
|
)
|
|
|
|
func GetStringResponse(prompt string) string {
|
|
fmt.Print(prompt + " ")
|
|
|
|
var response string
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
scanner.Scan()
|
|
response = scanner.Text()
|
|
|
|
return response
|
|
}
|
|
|
|
func GetYesNoResponse(prompt string) bool {
|
|
response := GetStringResponse(prompt)
|
|
return strings.ToUpper(response) == "Y"
|
|
}
|
|
|
|
func GetTriadicResponse(prompt string) logic.Triadic {
|
|
response := GetStringResponse(prompt)
|
|
|
|
switch strings.ToUpper(response) {
|
|
case "Y":
|
|
return logic.True
|
|
case "N":
|
|
return logic.False
|
|
default:
|
|
return logic.Either
|
|
}
|
|
}
|