2025-08-23 19:14:16 +02:00
|
|
|
package common
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"bufio"
|
|
|
|
|
"fmt"
|
|
|
|
|
"os"
|
2026-01-12 21:20:59 +01:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
2025-08-23 19:14:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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 {
|
2026-01-12 21:20:59 +01:00
|
|
|
promptStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("6")).Bold(true)
|
|
|
|
|
fmt.Printf("%s %s", promptStyle.Render(">"), question)
|
|
|
|
|
|
2025-08-23 19:14:16 +02:00
|
|
|
reader := bufio.NewReader(os.Stdin)
|
|
|
|
|
input, _, _ := reader.ReadLine()
|
2026-01-12 21:20:59 +01:00
|
|
|
return strings.TrimSpace(string(input))
|
2025-08-23 19:14:16 +02:00
|
|
|
}
|