kleinTodo/common/askUser.go
Darius klein ada2f0b760
All checks were successful
build and deploy kleinTodo / build (push) Successful in 35s
Cleanup + migrated to UUID usage
2026-01-12 21:22:46 +01:00

31 lines
601 B
Go

package common
import (
"bufio"
"fmt"
"os"
"strings"
"github.com/charmbracelet/lipgloss"
)
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 {
promptStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("6")).Bold(true)
fmt.Printf("%s %s", promptStyle.Render(">"), question)
reader := bufio.NewReader(os.Stdin)
input, _, _ := reader.ReadLine()
return strings.TrimSpace(string(input))
}