github.com/pavlo67/common@v0.5.3/common/cli/cli.go (about) 1 package cli 2 3 import ( 4 "bufio" 5 "fmt" 6 "os" 7 "strings" 8 9 "github.com/pavlo67/common/common/mathlib/sets" 10 ) 11 12 func Confirm(question string) bool { 13 reader := bufio.NewReader(os.Stdin) 14 fmt.Println(question + "? ") 15 16 text, _ := reader.ReadString('\n') 17 text = strings.Replace(text, "\n", "", -1) 18 text = strings.Replace(text, "\r", "", -1) 19 20 return sets.In([]string{"y", "yes"}, strings.ToLower(strings.TrimSpace(text))) 21 }