Documentation
¶
Overview ¶
Package confirm prompts the user for yes/no confirmation on stdin.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCannotPrompt = errors.New("stdin is not a terminal: confirmation required; pass --yes")
ErrCannotPrompt is returned instead of a decline when nothing can answer the prompt. Callers that want to say more about what went unconfirmed check CanPrompt themselves first and return their own error.
Functions ¶
func Action ¶ added in v0.21.0
Action prompts for confirmation of a destructive change other than a delete. warning describes what the caller is about to do, and question asks it. Like Delete, an unanswerable prompt is an error rather than a decline.
func CanPrompt ¶ added in v0.31.0
CanPrompt reports whether there is a human on the other end of r.
A prompt read from a closed or piped stdin comes back as a decline, so a command that only checks the answer exits 0 having done nothing — which is what an agent or CI job cannot tell apart from success. Delete and Action refuse outright rather than let that happen; this is exported for callers that want to explain the refusal in their own words.
A reader that is not the process's stdin at all — an injected one, as in tests — is promptable, since something is deliberately feeding it answers.
Types ¶
This section is empty.