confirm

package
v1.104.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Choice

type Choice string

Choice describes a prompt choice.

const (
	// Yes represents the "yes" choice.
	Yes Choice = "yes"
	// No represents the "no" choice.
	No Choice = "no"
	// Undecided is returned if the user was unable to make a choice.
	Undecided Choice = "undecided"
)

type Option

type Option func(*Prompt)

Option configures an option on a prompt.

func WithDefaultChoice

func WithDefaultChoice(c Choice) Option

WithDefaultChoice sets the default choice on the prompt.

func WithPersistPrompt

func WithPersistPrompt(v PersistPrompt) Option

WithPersistPrompt configures the prompt persistence behavior.

type PersistPrompt

type PersistPrompt int

PersistPrompt describes the behavior of the prompt after a choice is made.

const (
	// PersistPromptAlways always persists the prompt on the screen regardless of the choice.
	PersistPromptAlways PersistPrompt = iota
	// PersistPromptIfYes only persists the prompt on the screen if the choice is Yes.
	PersistPromptIfYes
	// PersistPromptIfNo only persists the prompt on the screen if the choice is No.
	PersistPromptIfNo
)

type Prompt

type Prompt struct {
	// contains filtered or unexported fields
}

Prompt describes a confirmation prompt.

func New

func New(text string, opts ...Option) *Prompt

New creates a new prompt.

func (*Prompt) Prompt

func (p *Prompt) Prompt() (Choice, error)

Prompt renders the prompt on the screen.

Jump to

Keyboard shortcuts

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