| 144 | } |
| 145 | |
| 146 | func promptToContinue(title string, message string, prompt string) bool { |
| 147 | fmt.Fprintln(os.Stderr, title) |
| 148 | fmt.Fprintln(os.Stderr, message) |
| 149 | fmt.Fprintf(os.Stderr, "%s [y/N]: ", prompt) |
| 150 | |
| 151 | reader := bufio.NewReader(os.Stdin) |
| 152 | response, err := reader.ReadString('\n') |
| 153 | if err != nil { |
| 154 | fmt.Fprintln(os.Stderr) |
| 155 | return false |
| 156 | } |
| 157 | |
| 158 | response = strings.TrimSpace(strings.ToLower(response)) |
| 159 | return response == "y" || response == "yes" |
| 160 | } |
| 161 | |
| 162 | // Call this function at the beginning of a command handler |
| 163 | // if you need to make authenticated requests. This will |