prompt

package
v0.69.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 before starting a bubbletea program. If stdin is not a terminal 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

Constants

This section is empty.

Variables

View Source
var ErrNotInteractive = errors.New("prompt: stdin is not a terminal")

ErrNotInteractive is returned by all constructors when stdin is not a terminal.

Functions

func Confirm

func Confirm(question string, def bool) (bool, error)

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

func Input(label string, masked bool) (string, error)

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 MultiSelect

func MultiSelect(title string, items []Item) ([]int, error)

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.

func Select

func Select(title string, opts []string) (int, error)

Select presents an interactive single-choice list to the user and returns the index of the chosen item.

Returns (0, ErrNotInteractive) when stdin is not a terminal.

Types

type Item

type Item struct {
	Label       string
	Preselected bool
}

Item is a selectable entry for MultiSelect.

Jump to

Keyboard shortcuts

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