menu

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCancelled = fmt.Errorf("cancelled")

ErrCancelled is returned when the user cancels an interactive menu.

View Source
var ErrNonInteractive = fmt.Errorf("non-interactive mode (use CLI flags instead)")

ErrNonInteractive is returned when a terminal is required but unavailable.

Functions

func Confirm

func Confirm(w io.Writer, r io.Reader, message string) bool

Confirm prompts for yes/no confirmation using a huh confirm widget. Falls back to a plain text prompt when stdin is not a terminal (e.g. in tests).

func ConfirmBulkDelete

func ConfirmBulkDelete(w io.Writer, r io.Reader, count int, itemType string) bool

ConfirmBulkDelete prompts user to confirm deletion of multiple items. Auto-confirms for single items.

func MultiSelect

func MultiSelect[T comparable](w io.Writer, items []T, itemType string, getName func(T) string, getInfo func(T) string) ([]T, error)

MultiSelect displays an interactive multi-select menu using huh. Space/x toggles selection, ctrl+a toggles all. Returns the selected items.

func SingleSelect

func SingleSelect[T comparable](w io.Writer, items []T, itemType string, getName func(T) string, getInfo func(T) string) (*T, error)

SingleSelect displays an interactive single-select menu using huh. The getName callback provides the display label; getInfo provides supplementary text shown in parentheses beside the label.

func SingleSelectWithCreate

func SingleSelectWithCreate[T comparable](w io.Writer, items []T, itemType string, getName func(T) string, getInfo func(T) string, createLabel string) (*T, bool, error)

SingleSelectWithCreate is like SingleSelect but adds a "Create new..." option at the bottom. Returns (item, isCreate, error). If isCreate is true, the item pointer is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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