(out io.Writer, msg string)
| 532 | } |
| 533 | |
| 534 | func confirm(out io.Writer, msg string) bool { |
| 535 | fmt.Fprintf(out, "%s [yes/no] ", msg) |
| 536 | |
| 537 | s := bufio.NewScanner(os.Stdin) |
| 538 | for { |
| 539 | s.Scan() |
| 540 | switch strings.ToLower(s.Text()) { |
| 541 | case "yes": |
| 542 | return true |
| 543 | case "no": |
| 544 | return false |
| 545 | default: |
| 546 | fmt.Fprint(out, "Please answer yes or no: ") |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | func handleInterrupt(cancel context.CancelFunc) { |
| 552 | c := make(chan os.Signal, 1) |