confirm

package
v0.46.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package confirm prompts the user for yes/no confirmation on stdin.

Index

Constants

This section is empty.

Variables

View Source
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

func Action(r io.Reader, w io.Writer, warning, question string) (bool, error)

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

func CanPrompt(r io.Reader) bool

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

func Delete(r io.Reader, w io.Writer, resource string, names ...string) (bool, error)

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL