choose

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package choose ...

Package choose ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetItemsKeys

func GetItemsKeys(items []list.Item) []string

GetItemsKeys return a slice of string representing the item's keys.

func Run

func Run(cfg *Config, items []list.Item) (string, error)

Run is used to prompt a list of available options to the user and retrieve the selection.

func ToListItem

func ToListItem(items []string) []list.Item

ToListItem converts a alice of strings in a slice of list.Item.

Types

type Config

type Config struct {
	Title           string
	ListHeight      int
	DefaultWidth    int
	ErrorMsg        string
	ShowHelp        bool
	ShowStatusBar   bool
	EnableFiltering bool // ShowHelp must be true otherwise you will now see the help
	// styles
	Styles Styles
}

Config represents the struct to configure the tui command.

type Item

type Item struct {
	Name string
	Desc string
}

Item represents an entry for choose (select) list.

func (Item) FilterValue

func (i Item) FilterValue() string

FilterValue returns the current value of the filter.

func (*Item) String

func (i *Item) String() string

type Styles

type Styles struct {
	PrefixIcon        string
	PrefixIconColor   lipgloss.AdaptiveColor
	TitleStyle        lipgloss.Style
	TitleBarStyle     lipgloss.Style
	ItemIcon          string
	ItemStyle         lipgloss.Style
	SelectedItemStyle lipgloss.Style
}

Styles is the struct representing the style configuration options.

func DefaultStyles

func DefaultStyles() (s Styles)

DefaultStyles sets the default styles theme.

Jump to

Keyboard shortcuts

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