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 {
|
2026-04-04 13:55:37 +02:00
|
|
|
switch strings.ToLower(AskUserString(fmt.Sprintf("%s (Y/N): ", question))) {
|
|
|
|
|
case "y", "yes":
|
2025-08-23 19:14:16 +02:00
|
|
|
return true
|
|
|
|
|
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)
|
|
|
|
|
|
2026-04-04 13:55:37 +02:00
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
|
|
|
if scanner.Scan() {
|
|
|
|
|
return strings.TrimSpace(scanner.Text())
|
|
|
|
|
}
|
|
|
|
|
return ""
|
2025-08-23 19:14:16 +02:00
|
|
|
}
|