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.
func Delete ¶
Delete prompts for delete confirmation for one or more named resources. It returns ErrCannotPrompt when nothing can answer, rather than reporting the unanswered prompt as a decline.
func MarkedNonInteractive ¶ added in v0.48.0
func MarkedNonInteractive() bool
MarkedNonInteractive reports whether the environment says no person is at the terminal: CI or VOLCANO_NONINTERACTIVE is set, or TERM=dumb, which some agents set when they run commands in a pseudo-terminal. A prompt that would otherwise run on a terminal is skipped when this is true.
Types ¶
This section is empty.