ui

package
v3.0.0-pre-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package ui contains some common UI elements.

Index

Constants

View Source
const (
	// MenuSeparator is the separator to use in the wizard menus.
	MenuSeparator = "────────────────"
)

Variables

View Source
var DefaultHuhKeymap = huh.NewDefaultKeyMap()
View Source
var ErrEmptyOptionalInput = errors.New("empty input in optional field")

ErrEmptyOptionalInput is returned when an optional input is empty.

View Source
var HuhTheme = ThemeBase16Ext

HuhTheme is the default Wizard theme.

Functions

func Confirm

func Confirm(msg string, _ bool, opt ...Option) (bool, error)

func FieldConfirm

func FieldConfirm(b *bool, msg string, _ bool, opt ...Option) huh.Field

func FieldFileInput

func FieldFileInput(filename *string, msg, descr string, opt ...Option) huh.Field

func FileSelector

func FileSelector(msg, descr string, opt ...Option) (string, error)

func Input

func Input(msg, help string, validateFn func(s string) error) (string, error)

Input shows a text input field with a custom validator.

func NoValidation

func NoValidation(s string) error

func String

func String(msg, help string) (string, error)

String asks user to input string, accepts an empty input.

func StringRequire

func StringRequire(msg, help string) (string, error)

StringRequire requires user to input string.

func ThemeBase16Ext

func ThemeBase16Ext() *huh.Theme

ThemeBase16Ext returns a modified Base16 theme based on huh.ThemeBase16.

func Time

func Time(msg string, _ ...Option) (time.Time, error)

Time asks the user to enter a date and time. For simplicity, the date and time are entered in two separate prompts. The date is optional, and if it is not given, the function terminates returning ErrEmptyOptionalInput. If the date is entered and is valid (checked with validators, you don't have to worry), the function will ask for time, which is then required.

func ValidateNotEmpty

func ValidateNotEmpty(s string) error

func ValidateNotExists

func ValidateNotExists(s string) error

Types

type ControlStyle

type ControlStyle struct {
	// Border defines the border style for the control.  It should not have
	// any color, otherwise it will paint everything that does not have
	// the color set.
	Border      lipgloss.Style
	Title       lipgloss.Style
	Description lipgloss.Style

	Text lipgloss.Style

	// Cursor is the pointer to the selected item, i.e. the ">" in a list.
	Cursor lipgloss.Style
	// SelectedLine is the style for the selected line in a list, next to the pointer.
	SelectedLine lipgloss.Style
	Unselected   lipgloss.Style

	SelectedFile   lipgloss.Style
	UnselectedFile lipgloss.Style
	DisabledFile   lipgloss.Style
	Directory      lipgloss.Style

	Options OptionStyle
}

type FileSystemModel

type FileSystemModel struct {
	SelectedFile string

	Propmt string
	// contains filtered or unexported fields
}

func NewFilePicker

func NewFilePicker(prompt string, homedir string, allowedExt ...string) FileSystemModel

func (FileSystemModel) Init

func (m FileSystemModel) Init() tea.Cmd

func (FileSystemModel) Update

func (m FileSystemModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (FileSystemModel) View

func (m FileSystemModel) View() string

type Option

type Option func(*inputOptions)

func WithDefaultFilename

func WithDefaultFilename(s string) Option

func WithHelp

func WithHelp(msg string) Option

WithHelp sets the help message.

func WithMustExist

func WithMustExist(b bool) Option

type OptionStyle

type OptionStyle struct {
	Section       lipgloss.Style
	Name          lipgloss.Style
	EnabledValue  lipgloss.Style
	DisabledValue lipgloss.Style
	SelectedName  lipgloss.Style
}

type Theme

type Theme struct {
	Focused ControlStyle
	Blurred ControlStyle

	StatusText lipgloss.Style
	Error      lipgloss.Style
	Help       help.Styles
}

func DefaultTheme

func DefaultTheme() Theme

Directories

Path Synopsis
Package ask provides common functions for asking questions for getting user input on dump and export parameters.
Package ask provides common functions for asking questions for getting user input on dump and export parameters.
bubbles
datepicker
Package datepicker provides a bubble tea component for viewing and selecting a date from a monthly view.
Package datepicker provides a bubble tea component for viewing and selecting a date from a monthly view.
Package dumpui provides a universal wizard for running dump-family commands.
Package dumpui provides a universal wizard for running dump-family commands.
Package updaters contains the models that wrap the variable and provide the UI for changing their values.
Package updaters contains the models that wrap the variable and provide the UI for changing their values.

Jump to

Keyboard shortcuts

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