MCPcopy Create free account
hub / github.com/conventionalcommit/commitlint / promptConfirm

Function promptConfirm

internal/cmd/remove.go:56–69  ·  view source on GitHub ↗

promptConfirm prints prompt and waits for the user to type y/yes or anything else. Returns true only when the user confirms with "y" or "yes" (case-insensitive).

(prompt string)

Source from the content-addressed store, hash-verified

54// promptConfirm prints prompt and waits for the user to type y/yes or anything else.
55// Returns true only when the user confirms with "y" or "yes" (case-insensitive).
56func promptConfirm(prompt string) (bool, error) {
57 fmt.Printf("%s [y/N]: ", prompt)
58 var response string
59 _, err := fmt.Scanln(&response)
60 if err != nil {
61 // empty Enter is reported by fmt.Scanln as "unexpected newline"
62 if err.Error() == "unexpected newline" {
63 return false, nil
64 }
65 return false, err
66 }
67 response = strings.TrimSpace(strings.ToLower(response))
68 return response == "y" || response == "yes", nil
69}

Callers 1

gitRemoveHookFunction · 0.85

Calls 1

ErrorMethod · 0.80

Tested by

no test coverage detected