askForConfirmation prints prompt to stdout and waits for response from the user Expected answers are: "yes", "y", "no", "n" Answers are internally converted to lower case. The default answer is "no" ([y/N])
(prompt string)
| 56 | // |
| 57 | // The default answer is "no" ([y/N]) |
| 58 | func askForConfirmation(prompt string) bool { |
| 59 | var retVal bool |
| 60 | |
| 61 | ctx := context.Background() |
| 62 | retValCh, errCh := askForConfirmationAsync(ctx, prompt, nil) |
| 63 | |
| 64 | select { |
| 65 | case val := <-retValCh: |
| 66 | retVal = val |
| 67 | case err := <-errCh: |
| 68 | logrus.Debugf("Failed to ask for confirmation: %s", err) |
| 69 | retVal = false |
| 70 | } |
| 71 | |
| 72 | return retVal |
| 73 | } |
| 74 | |
| 75 | func askForConfirmationAsync(ctx context.Context, |
| 76 | prompt string, |
no test coverage detected
searching dependent graphs…