tui

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUserAborted = huh.ErrUserAborted

Functions

func AppendHistory

func AppendHistory(path, line string)

func Bold

func Bold(s string) string

func Cyan

func Cyan(s string) string

func Dim

func Dim(s string) string

func Green

func Green(s string) string

func HistoryFile

func HistoryFile(name string) string

func LoadHistory

func LoadHistory(path string) []string

func Magenta

func Magenta(s string) string

func Red

func Red(s string) string

func TruncateMiddle

func TruncateMiddle(s string, n int) string

func Yellow

func Yellow(s string) string

Types

type AppHooks

type AppHooks struct {
	BeforeRun     func(ctx RunContext, name string, args []string) error
	OnUnknown     func(ctx RunContext, args []string) (handled bool, err error)
	NeedsContext  func(name string, args []string) bool
	Banner        func(ctx RunContext) string
	GlobalHelp    func(ctx RunContext, groups map[string][]GroupEntry, flagHelpText string) string
	HelpFor       func(ctx RunContext, c *CLICommand, canonical string) string
	Prompt        func(ctx RunContext) string
	REPLQuit      func(word string) bool
	DispatchError func(ctx RunContext, err error)
	EnterREPL     func(ctx RunContext) error
}

type CLIApp

type CLIApp struct {
	// contains filtered or unexported fields
}

func NewCLIApp

func NewCLIApp(name, version string, hooks AppHooks) *CLIApp

func (*CLIApp) DispatchREPLLine

func (a *CLIApp) DispatchREPLLine(lineArgs []string) (quit bool, err error)

func (*CLIApp) Execute

func (a *CLIApp) Execute(cliArgs []string) error

func (*CLIApp) FlagHelpText

func (a *CLIApp) FlagHelpText() string

func (*CLIApp) Flags

func (a *CLIApp) Flags() *FlagSet

func (*CLIApp) HelpForCmd

func (a *CLIApp) HelpForCmd(c *CLICommand, canonical string) string

func (*CLIApp) Hooks

func (a *CLIApp) Hooks() AppHooks

func (*CLIApp) InstallHelpVersionFlags

func (a *CLIApp) InstallHelpVersionFlags()

func (*CLIApp) IsKnownCommand

func (a *CLIApp) IsKnownCommand(word string) bool

func (*CLIApp) Register

func (a *CLIApp) Register(c *CLICommand)

func (*CLIApp) Resolve

func (a *CLIApp) Resolve(name string) (*CLICommand, string)

func (*CLIApp) SetUserData

func (a *CLIApp) SetUserData(ud any)

func (*CLIApp) UserData

func (a *CLIApp) UserData() any

type CLICommand

type CLICommand struct {
	Use     string
	Aliases []string
	Short   string
	Long    string
	Run     func(ctx RunContext, args []string) error
	MinArgs int
	MaxArgs int
	Hidden  bool
	// AllowFlags permits "-x"-style tokens after the subcommand name so the
	// command can parse its own flag set (redis-cli style). Without it, dash
	// tokens after a subcommand are rejected as misplaced global flags.
	AllowFlags bool
}

type Choice

type Choice struct {
	Label string
	Value string
}

type CmdEntry

type CmdEntry struct {
	Use   string
	Short string
	Run   func(args []string) (out string, err error)
}

type FlagSet

type FlagSet struct {
	// contains filtered or unexported fields
}

func (*FlagSet) BoolVar

func (f *FlagSet) BoolVar(p *bool, long, short string, def bool, usage string)

func (*FlagSet) IntVar

func (f *FlagSet) IntVar(p *int, long, short string, def int, usage string)

func (*FlagSet) StringVar

func (f *FlagSet) StringVar(p *string, long, short, def, usage string)

type GroupEntry

type GroupEntry struct {
	Use   string
	Short string
}

type IO

type IO struct {
	In    io.Reader
	Out   io.Writer
	Err   io.Writer
	FSOut io.Writer
}

func DefaultIO

func DefaultIO() IO

type InputField

type InputField struct {
	Name        string
	Title       string
	Placeholder string
	Default     string
	Required    bool
	Validate    func(string) error
}

type Prompter

type Prompter struct{}

func NewPrompter

func NewPrompter() *Prompter

func (*Prompter) Confirm

func (p *Prompter) Confirm(title string, defYes bool) (bool, error)

func (*Prompter) ConfirmKeyword

func (p *Prompter) ConfirmKeyword(keyword string, action string) (bool, error)

func (*Prompter) Input

func (p *Prompter) Input(f InputField) (string, error)

func (*Prompter) Select

func (p *Prompter) Select(title string, choices []Choice, def string) (string, error)

func (*Prompter) SelectNth

func (p *Prompter) SelectNth(title string, choices []Choice, defIdx int) (int, error)

func (*Prompter) Text

func (p *Prompter) Text(title string, desc string, def string, validate func(string) error) (string, error)

type RunContext

type RunContext struct {
	RawArgs  []string
	IO       IO
	UserData any
}

type TabDef

type TabDef struct {
	Name    string
	Visible func() bool
	Entries []CmdEntry
}

type TabShell

type TabShell struct {
	// contains filtered or unexported fields
}

func NewTabShell

func NewTabShell(tabs []TabDef) *TabShell

func (*TabShell) Init

func (m *TabShell) Init() tea.Cmd

func (*TabShell) PrependBanner

func (m *TabShell) PrependBanner(s string)

func (*TabShell) Update

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

func (*TabShell) View

func (m *TabShell) View() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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