All checks were successful
build and deploy kleinTodo / build (push) Successful in 35s
31 lines
601 B
Go
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))
|
|
}
|