confirmation

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfirmDestructiveOperation

func ConfirmDestructiveOperation(ctx context.Context, prompt string, force bool) (bool, error)

ConfirmDestructiveOperation prompts the user for confirmation before a destructive operation. It returns true if the operation should proceed. The prompt is skipped (returns true) when force is set or agent mode is active.

The read honors ctx cancellation — a Ctrl-C (which the root process wires into ctx via signal.NotifyContext) unblocks the prompt with context.Canceled. Without this, the SIGINT handler would intercept the signal but the bufio read would keep blocking, leaving the user stuck until SIGKILL.

On cancellation the stdin-reader goroutine is leaked (it stays blocked on os.Stdin). That is acceptable: cancellation only happens on the way to process exit, and Go's runtime tears the goroutine down with the process.

func SetReaderForTest added in v1.14.0

func SetReaderForTest(r io.Reader) (restore func())

SetReaderForTest overrides the confirmation input reader, returning a function that restores the previous reader. It is intended for use only from test code in other packages that need to simulate user input.

Types

This section is empty.

Jump to

Keyboard shortcuts

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