Help us shape the future of Go! Take the 2026 Go Developer Survey

ui

package
v1.49.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package ui provides reusable interactive terminal UI components, standardized theming, and wrappers around the "charmbracelet/huh" and "charmbracelet/bubbles" libraries.

This package centralizes all interactive CLI components ensuring a consistent user experience and visual identity across the entire eng CLI application. It abstract away the complexity of managing terminal prompts and concurrent spinners.

Available Features

  • **Theming**: The `theme.EngTheme()` function supplies a consistent, adaptive light/dark mode HSL color palette across all interactive prompts.
  • **Prompts**: Standardized functions for user interaction:
  • `Confirm(message string, defaultVal bool)`: Yes/No prompts.
  • `Input(message string, defaultVal string)`: Text input.
  • `Select(message string, options []string, defaultVal string)`: Single selection.
  • `MultiSelect(message string, options []string)`: Multiple selection.
  • `Password(message string)`: Secret text input.
  • **Spinners**: Beautiful and thread-safe progress spinners.
  • `Spinner`: Single operation status and progress.
  • `MultiSpinner`: For displaying multiple concurrent operations (e.g., parallel git pulls, downloading files, system updates).

Testing

The prompt functions within this package are exposed as variables (e.g., `var Confirm = ConfirmImpl`) to allow them to be easily mocked during unit testing.

Index

Constants

This section is empty.

Variables

View Source
var (
	Confirm     = ConfirmImpl
	Input       = InputImpl
	Select      = SelectImpl
	MultiSelect = MultiSelectImpl
	Password    = PasswordImpl
)

Wrapper functions for testing.

View Source
var DisableProgress = false

DisableProgress can be set to true in tests to prevent progress goroutines from spawning.

Out is the writer used for spinner output. Tests may replace it.

Functions

func ConfirmImpl added in v1.14.0

func ConfirmImpl(message string, defaultVal bool) (bool, error)

ConfirmImpl prompts the user with a yes/no question using the default theme.

func GetTerminalWidth added in v1.29.0

func GetTerminalWidth() int

GetTerminalWidth returns the current terminal width in columns, defaulting to 100 if unparseable.

func HelpFunc added in v1.27.0

func HelpFunc(c *cobra.Command, args []string)

HelpFunc returns a Cobra help function that formats help output using Lip Gloss styles.

func InputImpl added in v1.14.0

func InputImpl(message, defaultVal string) (string, error)

InputImpl prompts the user for text input using the default theme.

func MultiSelectImpl added in v1.14.0

func MultiSelectImpl(message string, options, defaultSelected []string) ([]string, error)

MultiSelectImpl prompts the user to select multiple options from a list using the default theme.

func PasswordImpl added in v1.14.0

func PasswordImpl(message string) (string, error)

PasswordImpl prompts the user for a secret text input using the default theme.

func RenderContainerTable added in v1.28.0

func RenderContainerTable(stackName string, containerList []containers.ContainerDetail, termWidth int) string

RenderContainerTable renders a detailed Lip Gloss table for containers in a specific stack.

func RenderStackTable added in v1.28.0

func RenderStackTable(stacks []containers.Stack, termWidth int) string

RenderStackTable renders a Lip Gloss table showing high-level status for Compose stacks.

func RunContainersPager added in v1.29.0

func RunContainersPager(content string) error

RunContainersPager launches an interactive scrollable viewport displaying rendered container status content.

func SelectImpl added in v1.14.0

func SelectImpl(message string, options []string, defaultVal string) (string, error)

SelectImpl prompts the user to select an option from a list using the default theme.

func UsageFunc added in v1.27.0

func UsageFunc(c *cobra.Command) error

UsageFunc returns a Cobra usage function that formats usage output using Lip Gloss styles.

Types

type MultiSpinner

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

MultiSpinner manages multiple concurrent progress indicators.

func NewMultiSpinner

func NewMultiSpinner() (*MultiSpinner, error)

NewMultiSpinner creates a new multi-spinner manager.

func (*MultiSpinner) AddSpinner

func (m *MultiSpinner) AddSpinner(text string) ProgressSpinner

AddSpinner adds a new spinner to the display.

func (*MultiSpinner) Stop

func (m *MultiSpinner) Stop()

Stop stops the multi-spinner.

type ProgressSpinner added in v1.14.0

type ProgressSpinner interface {
	UpdateText(text string)
	Success(text ...interface{})
	Fail(text ...interface{})
	Warning(text ...interface{})
	Info(text ...interface{})
}

ProgressSpinner defines the interface for spinner operations.

type Spinner

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

Spinner manages progress bars and status updates using Lip Gloss and Bubbles.

func NewProgressSpinner

func NewProgressSpinner(message string) *Spinner

NewProgressSpinner creates a spinner that displays progress as a bar.

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner creates a new spinner with default theme styling.

func (*Spinner) Logf

func (s *Spinner) Logf(format string, a ...interface{})

Logf prints a formatted message above the progress bar.

func (*Spinner) SetProgressBar

func (s *Spinner) SetProgressBar(percent float64, msg ...string)

SetProgressBar sets the progress of the bar (0.0 to 1.0).

func (*Spinner) Start

func (s *Spinner) Start()

Start displays initial spinner state.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop completes progress output and clears active indicator.

func (*Spinner) UpdateMessage

func (s *Spinner) UpdateMessage(msg string)

UpdateMessage updates the message displayed next to the progress bar.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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