Function
promptYesNo
(out io.Writer, in *bufio.Reader, prompt string, def bool)
Source from the content-addressed store, hash-verified
| 273 | } |
| 274 | |
| 275 | func promptYesNo(out io.Writer, in *bufio.Reader, prompt string, def bool) bool { |
| 276 | suffix := " (Y/n) " |
| 277 | if !def { |
| 278 | suffix = " (y/N) " |
| 279 | } |
| 280 | fmt.Fprint(out, prompt+suffix) |
| 281 | line, err := in.ReadString('\n') |
| 282 | if err != nil { |
| 283 | return def |
| 284 | } |
| 285 | line = strings.TrimSpace(strings.ToLower(line)) |
| 286 | switch line { |
| 287 | case "": |
| 288 | return def |
| 289 | case "y", "yes": |
| 290 | return true |
| 291 | case "n", "no": |
| 292 | return false |
| 293 | default: |
| 294 | return def |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | func randomUUID() string { |
| 299 | var b [16]byte |
Tested by
no test coverage detected