ux

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StyleInfo    = lipgloss.NewStyle().Foreground(colorInfo)
	StyleSuccess = lipgloss.NewStyle().Foreground(colorSuccess)
	StyleError   = lipgloss.NewStyle().Foreground(colorError)
	StyleWarning = lipgloss.NewStyle().Foreground(colorWarning)
	StyleDebug   = lipgloss.NewStyle().Foreground(colorDebug)
	StyleMuted   = lipgloss.NewStyle().Foreground(colorMuted)
	StyleBold    = lipgloss.NewStyle().Bold(true)
	StyleSection = lipgloss.NewStyle().Bold(true)
	StyleAccent  = lipgloss.NewStyle().Foreground(colorAccent)

	// TableBorder is the default style for lipgloss/table borders.
	TableBorder = lipgloss.NewStyle().Foreground(colorBorder)
)

Styles — exported so commands can reuse instead of defining their own.

View Source
var ErrUserAborted = huh.ErrUserAborted

ErrUserAborted is returned when the user presses Esc during a prompt.

View Source
var LogPlainText bool

LogPlainText disables spinners and uses plain logger output when true. Set before using any ux functions (e.g. when not a TTY or in CI).

View Source
var OutputFormat = "text"

OutputFormat controls how PrintTable and PrintData emit output. Values: "text" (default lipgloss table), "json", "yaml".

View Source
var Verbose bool

Verbose enables streaming of build output to stdout instead of suppressing it. Implies LogPlainText. Set by --debug.

Functions

func Debugf added in v0.4.0

func Debugf(format string, a ...any)

Debugf prints a formatted debug message when Verbose (--debug) is enabled.

func GetConfirmation

func GetConfirmation(message string) (bool, error)

GetConfirmation shows an interactive confirmation prompt (defaults to true).

func GetMultiSelection added in v0.4.0

func GetMultiSelection(message string, options []string, defaultOptions []string) ([]string, error)

GetMultiSelection shows an interactive multi-select (checkbox) prompt and returns all selected options. defaultOptions are pre-checked. Returns huh.ErrUserAborted if the user presses Esc or Ctrl+C.

func GetSelection added in v0.3.0

func GetSelection(message string, options []string) (string, error)

GetSelection shows an interactive selection prompt and returns the chosen option.

func GetSelectionKV added in v0.4.0

func GetSelectionKV(message string, options []SelectOption) (string, error)

GetSelectionKV shows an interactive selection with separate display labels and values. Returns the Value of the selected option.

func Info added in v0.4.0

func Info(message string)

Info prints an info-styled message.

func InteractiveTable added in v0.5.0

func InteractiveTable(
	headers []string,
	rows [][]string,
	sortHandler func(key SortKey) [][]string,
)

InteractiveTable displays headers+rows in an interactive bubbles/table TUI. sortHandler is called when the user presses a sort key (r/s/z/p) and should return the re-sorted rows. Falls back to PrintTable for non-TTY or non-text mode.

func PrintBuildErrorHint added in v0.5.0

func PrintBuildErrorHint(hint *BuildErrorHint)

PrintBuildErrorHint renders a user-facing error panel for a build failure hint.

func PrintData added in v0.5.0

func PrintData(v any)

PrintData serialises any Go value in the current OutputFormat. Use this when commands build typed structs (e.g. for models output). In text mode it falls back to JSON so the caller always gets parseable output.

func PrintTable added in v0.5.0

func PrintTable(headers []string, rows [][]string)

PrintTable renders headers+rows in the current OutputFormat. text: lipgloss bordered table. json/yaml: array of objects keyed by header.

func Println

func Println(message string)

Println prints a styled line (or plain info when LogPlainText is set).

func SortKeyString added in v0.5.0

func SortKeyString(key SortKey) string

SortKeyString converts a SortKey to the string value passed to RankModels sortBy.

func SuccessMsg added in v0.4.0

func SuccessMsg(message string)

SuccessMsg prints a success-styled message (standalone, not spinner).

func Warn added in v0.4.0

func Warn(message string)

Warn prints a warning-styled message.

Types

type BuildErrorHint added in v0.5.0

type BuildErrorHint struct {
	Title string
	Body  string
	Fixes []string
}

BuildErrorHint describes a user-facing explanation and fix for a known build failure.

func ClassifyBuildOutput added in v0.5.0

func ClassifyBuildOutput(output string) *BuildErrorHint

ClassifyBuildOutput scans docker build output for known error patterns and returns a user-facing hint. Returns nil when no pattern matches.

type ProgressSpinner

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

ProgressSpinner displays an animated spinner with a message. In plain-text mode it falls back to simple log lines.

func NewProgressSpinner

func NewProgressSpinner(message string) *ProgressSpinner

NewProgressSpinner creates and starts a spinner, or logs the message if in plain-text mode.

func (*ProgressSpinner) Fail

func (ps *ProgressSpinner) Fail(message string) *ProgressSpinner

Fail stops the spinner and prints a failure message.

func (*ProgressSpinner) Stop

func (ps *ProgressSpinner) Stop()

Stop clears the spinner without leaving any output.

func (*ProgressSpinner) Success

func (ps *ProgressSpinner) Success(message string) *ProgressSpinner

Success stops the spinner and prints a success message.

func (*ProgressSpinner) UpdateText

func (ps *ProgressSpinner) UpdateText(message string) *ProgressSpinner

UpdateText updates the spinner text or prints the message.

type SelectOption added in v0.4.0

type SelectOption struct {
	Label string
	Value string
}

SelectOption pairs a display label with a value for typed selection.

type SortKey added in v0.5.0

type SortKey string

SortKey identifies the column being sorted in the interactive table.

const (
	SortRecommended SortKey = "r"
	SortSWE         SortKey = "s"
	SortSpeed       SortKey = "z"
	SortSize        SortKey = "p"
)

Jump to

Keyboard shortcuts

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