MCPcopy
hub / github.com/containers/toolbox / askForConfirmation

Function askForConfirmation

src/cmd/utils.go:58–73  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

56//
57// The default answer is "no" ([y/N])
58func 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
75func askForConfirmationAsync(ctx context.Context,
76 prompt string,

Callers 1

runCommandFunction · 0.85

Calls 1

askForConfirmationAsyncFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…