Documentation
¶
Overview ¶
Package prompt provides reusable terminal UI widgets built on charm.land/bubbletea/v2 and charm.land/bubbles/v2.
Every public constructor checks whether stdin is an interactive terminal and whether stderr or stdout can render terminal output before starting a bubbletea program. If either side is unavailable, the constructor returns (zero, ErrNotInteractive) immediately so callers in CI / pipe mode can detect the condition and fall back to non-interactive paths without any risk of hanging.
Index ¶
- Variables
- func CanPrompt() bool
- func Confirm(question string, def bool) (bool, error)
- func Input(label string, masked bool) (string, error)
- func InputWithSuggestions(label string, masked bool, suggestions []string) (string, error)
- func MultiSelect(title string, items []Item) ([]int, error)
- func Select(title string, opts []string) (int, error)
- type Item
Constants ¶
This section is empty.
Variables ¶
var ErrInterrupted = errors.New("prompt: interrupted")
ErrInterrupted is returned when the user aborts an interactive prompt.
var ErrNotInteractive = errors.New("prompt: stdin is not a terminal")
ErrNotInteractive is returned by all constructors when stdin is not a terminal.
Functions ¶
func CanPrompt ¶ added in v0.75.6
func CanPrompt() bool
CanPrompt reports whether prompts can safely read input and render output.
func Confirm ¶
Confirm asks a yes/no question. def is the default answer shown in the prompt (used when the user presses Enter without typing y/n).
Returns (false, ErrNotInteractive) when stdin is not a terminal.
func Input ¶
Input prompts the user for a single-line text value. When masked is true the input is displayed as asterisks (suitable for passwords/tokens).
Returns ("", ErrNotInteractive) when stdin is not a terminal.
func InputWithSuggestions ¶ added in v0.75.3
InputWithSuggestions prompts the user for a single-line text value and shows completion suggestions when suggestions is non-empty. Tab accepts the current suggestion using the underlying bubbles textinput behavior.
func MultiSelect ¶
MultiSelect presents an interactive multi-choice list. Returns the indices of all selected items. Items can be pre-selected via Item.Preselected.
Returns (nil, ErrNotInteractive) when stdin is not a terminal.