Documentation
¶
Overview ¶
Package confirm provides confirmation prompts for destructive operations.
Index ¶
- type Choice
- type ChoiceResult
- type Prompter
- func (p *Prompter) Confirm(message string, skipConfirm bool) (bool, error)
- func (p *Prompter) ConfirmAction(action, target string, skipConfirm bool) (bool, error)
- func (p *Prompter) ConfirmChoice(message string, choices []Choice) (ChoiceResult, error)
- func (p *Prompter) ConfirmDelete(target string, skipConfirm bool) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChoiceResult ¶ added in v0.7.0
type ChoiceResult int
ChoiceResult represents the result of a choice prompt.
const ( // ChoiceCancelled indicates the user cancelled the prompt. ChoiceCancelled ChoiceResult = -1 )
type Prompter ¶
type Prompter struct {
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
// Target is a provider-neutral, human-readable description of where the
// operation applies (e.g. "my-profile (123456789012 / us-east-1)" for AWS or
// "project my-gcloud-project" for Google Cloud). When set, it is shown before
// the prompt. It takes precedence over the AWS-specific fields below.
Target string
// AccountID/Region/Profile describe the AWS target. They are used only when
// Target is empty, preserving the original AWS confirmation output.
AccountID string
Region string
Profile string
}
Prompter handles confirmation prompts.
func (*Prompter) Confirm ¶
Confirm displays a confirmation prompt and returns true if the user confirms. If skipConfirm is true, returns true without prompting.
func (*Prompter) ConfirmAction ¶
ConfirmAction is a convenience function for confirming an action.
func (*Prompter) ConfirmChoice ¶ added in v0.7.0
func (p *Prompter) ConfirmChoice(message string, choices []Choice) (ChoiceResult, error)
ConfirmChoice displays a multiple choice prompt and returns the selected index. Returns ChoiceCancelled (-1) if the user cancels or selects cancel option. The first choice (index 0) is the default when user just presses Enter.
Click to show internal directories.
Click to hide internal directories.