2024-06-10 15:34:16 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2024-06-11 09:08:07 +00:00
|
|
|
"bufio"
|
2024-06-10 15:34:16 +00:00
|
|
|
"fmt"
|
2024-06-11 09:08:07 +00:00
|
|
|
"os"
|
2024-06-11 16:02:02 +00:00
|
|
|
"sevenkeys/logic"
|
2024-06-10 15:34:16 +00:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetStringResponse(prompt string) string {
|
|
|
|
fmt.Print(prompt + " ")
|
|
|
|
|
|
|
|
var response string
|
2024-06-11 09:08:07 +00:00
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
|
|
scanner.Scan()
|
|
|
|
response = scanner.Text()
|
2024-06-10 15:34:16 +00:00
|
|
|
|
|
|
|
return response
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetYesNoResponse(prompt string) bool {
|
|
|
|
response := GetStringResponse(prompt)
|
|
|
|
return strings.ToUpper(response) == "Y"
|
|
|
|
}
|
2024-06-11 16:02:02 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|