Documentation
¶
Overview ¶
tui/prompt/errors.go
Package prompt provides interactive input prompts. All prompts return typed sentinel errors for cancellation and environment-driven refusal; callers check with errors.Is.
tui/prompt/prompt.go
tui/prompt/secret.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAgentMode = errors.New("prompt refused in agent mode")
ErrAgentMode is returned when output.Mode is Agent and no pre-answer was supplied. Callers should branch on a tool-level --yes (or similar) flag before calling a prompt, and only call through when interactive input is actually safe.
var ErrCancelled = errors.New("prompt cancelled")
ErrCancelled is returned when the user presses Ctrl-C or stdin reaches EOF during a prompt. The terminal mode is restored before this error returns.
var ErrNoTTY = errors.New("stdin is not a terminal")
ErrNoTTY is returned when stdin is not a terminal and the prompt cannot be satisfied.
Functions ¶
func Confirm ¶
Confirm reads a y/n answer. defaultYes controls the default when the user just presses Enter.
func Prompt ¶
Prompt reads a visible line of input. Returns ErrAgentMode in Agent mode and ErrNoTTY when stdin is not a terminal.
func Secret ¶
func Secret(label string, opts ...SecretOption) (string, error)
Secret reads a password with masked echo by default. Each typed character prints '*' to stderr. Backspace (BS or DEL) erases one character in both buffer and echo. Ctrl-C (0x03) returns ErrCancelled. Enter commits.
Non-TTY stdin → ErrNoTTY. Agent mode → ErrAgentMode.
Types ¶
type SecretOption ¶
type SecretOption func(*secretConfig)
SecretOption configures Secret behavior.
func WithNoMask ¶
func WithNoMask() SecretOption
WithNoMask disables the default echoed-asterisk behavior; input is fully silent. Use sparingly — users generally benefit from seeing that keystrokes registered.