more terminal utility functions

This commit is contained in:
Kistaro Windrider 2023-04-02 00:09:17 -07:00
parent c73545fd07
commit 3eb087201f
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -2,6 +2,7 @@ package cardsim
import (
"fmt"
"os"
"strconv"
"strings"
)
@ -123,3 +124,22 @@ func pickNextAction[C StatsCollection](p *Player[C]) (isCard bool, cardIdx int,
func cls() {
fmt.Println("\033[H\033[2J")
}
func divider() {
fmt.Println()
fmt.Println(SectionBreak.String())
fmt.Println()
}
func confirmQuit() {
divider()
fmt.Println("Are you sure you want to quit? (Y/N) ")
var s string
fmt.Scanln(&s)
s = strings.TrimSpace(s)
s = strings.ToLower(s)
if strings.HasPrefix(s, "y") {
fmt.Println("Bye!")
os.Exit(0)
}
}