selector

package
v0.76.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCancelled = errors.New("selection cancelled")

ErrCancelled is returned by FromList when the user aborts the picker.

Functions

func FromList

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

FromList renders an interactive single-choice list and returns the index of the chosen item, or ErrCancelled if the user aborts. It renders to stderr so it does not pollute stdout. Callers must ensure they are attached to an interactive terminal (e.g. term.IsTerminal(os.Stdin.Fd())) before calling.

Types

type Item

type Item struct {
	Label string
	Note  string
}

Item is a single row in the picker: a primary label plus an optional grey subtext (e.g. "(running)" or an image name).

Jump to

Keyboard shortcuts

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