Documentation
¶
Index ¶
- Variables
- func Confirm(w io.Writer, r io.Reader, message string) bool
- func ConfirmBulkDelete(w io.Writer, r io.Reader, count int, itemType string) bool
- func MultiSelect[T comparable](w io.Writer, items []T, itemType string, getName func(T) string, ...) ([]T, error)
- func SingleSelect[T comparable](w io.Writer, items []T, itemType string, getName func(T) string, ...) (*T, error)
- func SingleSelectWithCreate[T comparable](w io.Writer, items []T, itemType string, getName func(T) string, ...) (*T, bool, error)
Constants ¶
This section is empty.
Variables ¶
var ErrCancelled = fmt.Errorf("cancelled")
ErrCancelled is returned when the user cancels an interactive menu.
var ErrNonInteractive = fmt.Errorf("non-interactive mode (use CLI flags instead)")
ErrNonInteractive is returned when a terminal is required but unavailable.
Functions ¶
func Confirm ¶
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 ¶
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.