prompt

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNonInteractive = errors.New("cannot prompt in non-interactive mode")

ErrNonInteractive is returned when prompting in non-interactive mode.

Functions

This section is empty.

Types

type HuhPrompter

type HuhPrompter struct{}

HuhPrompter implements Prompter using the charmbracelet/huh library.

func NewHuhPrompter

func NewHuhPrompter() *HuhPrompter

NewHuhPrompter creates a new huh-based prompter.

func (*HuhPrompter) Confirm

func (p *HuhPrompter) Confirm(title string, defaultValue bool) (bool, error)

func (*HuhPrompter) Input

func (p *HuhPrompter) Input(title string, defaultValue string) (string, error)

func (*HuhPrompter) MultiSelect

func (p *HuhPrompter) MultiSelect(title string, options []string) ([]string, error)

func (*HuhPrompter) Select

func (p *HuhPrompter) Select(title string, options []string) (string, error)

type NoopPrompter

type NoopPrompter struct{}

NoopPrompter returns errors for all prompts (non-interactive mode).

func (*NoopPrompter) Confirm

func (p *NoopPrompter) Confirm(title string, defaultValue bool) (bool, error)

func (*NoopPrompter) Input

func (p *NoopPrompter) Input(title string, defaultValue string) (string, error)

func (*NoopPrompter) MultiSelect

func (p *NoopPrompter) MultiSelect(title string, options []string) ([]string, error)

func (*NoopPrompter) Select

func (p *NoopPrompter) Select(title string, options []string) (string, error)

type Prompter

type Prompter interface {
	// Select presents options and returns the selected value.
	Select(title string, options []string) (string, error)

	// Input prompts for text input.
	Input(title string, defaultValue string) (string, error)

	// Confirm prompts for yes/no.
	Confirm(title string, defaultValue bool) (bool, error)

	// MultiSelect allows selecting multiple options.
	MultiSelect(title string, options []string) ([]string, error)
}

Prompter defines the interface for interactive user prompts.

Jump to

Keyboard shortcuts

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