tui

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllBindings

func AllBindings() []key.Binding

AllBindings returns all default key bindings.

func ConnectionIndicator

func ConnectionIndicator(connected bool) string

ConnectionIndicator creates a connection status indicator.

func CounterIndicator

func CounterIndicator(label string, current, total int) string

CounterIndicator creates a counter display for the status bar.

func HelpBinding

func HelpBinding(keys, desc string) string

HelpBinding creates a single help binding display.

func IsDown

func IsDown(msg tea.KeyMsg) bool

IsDown returns true if the key message matches down navigation keys.

func IsEnter

func IsEnter(msg tea.KeyMsg) bool

IsEnter returns true if the key message matches enter key.

func IsEscape

func IsEscape(msg tea.KeyMsg) bool

IsEscape returns true if the key message matches escape key.

func IsHelp

func IsHelp(msg tea.KeyMsg) bool

IsHelp returns true if the key message matches help key.

func IsLeft

func IsLeft(msg tea.KeyMsg) bool

IsLeft returns true if the key message matches left navigation keys.

func IsQuit

func IsQuit(msg tea.KeyMsg) bool

IsQuit returns true if the key message matches quit keys.

func IsRight

func IsRight(msg tea.KeyMsg) bool

IsRight returns true if the key message matches right navigation keys.

func IsTab

func IsTab(msg tea.KeyMsg) bool

IsTab returns true if the key message matches tab key.

func IsUp

func IsUp(msg tea.KeyMsg) bool

IsUp returns true if the key message matches up navigation keys.

func ModeIndicator

func ModeIndicator(mode string, active bool) string

ModeIndicator creates a styled mode indicator for the status bar.

func NavigationBindings() []key.Binding

NavigationBindings returns common navigation key bindings.

func QuickHelp

func QuickHelp(pairs ...string) string

QuickHelp creates a quick help string from key-description pairs.

func QuitBindings

func QuitBindings() []key.Binding

QuitBindings returns quit-related key bindings.

func RenderBadge

func RenderBadge(text string, render ...func(string) string) string

RenderBadge renders text as a styled badge. If no render function is provided, uses BadgeStyle.

func RenderBytes

func RenderBytes(bytes int64) string

RenderBytes renders a byte count in human-readable format.

func RenderCountBadge

func RenderCountBadge(count int, label string) string

RenderCountBadge renders a count with a label, like "3 tasks".

func RenderDetailPanel

func RenderDetailPanel(title string, pairs []KeyValuePair, width int) string

RenderDetailPanel renders a panel with key-value pairs.

func RenderDivider

func RenderDivider(width int) string

RenderDivider renders a horizontal divider line.

func RenderEmptyState

func RenderEmptyState(message string, width, height int) string

RenderEmptyState renders a centered empty state message.

func RenderError

func RenderError(err error, width int) string

RenderError renders an error message.

func RenderHeader

func RenderHeader(cfg HeaderConfig) string

RenderHeader renders a header with title, optional subtitle, and timestamp.

func RenderHelpBar

func RenderHelpBar(bindings []key.Binding, width int) string

RenderHelpBar renders a help bar with the given bindings.

func RenderHelpGrid

func RenderHelpGrid(bindings []key.Binding, columns, width int) string

RenderHelpGrid renders bindings in a grid layout.

func RenderInfoPanel

func RenderInfoPanel(title, content string, width int) string

RenderInfoPanel renders a simple info panel with title and content.

func RenderKeyValueTable

func RenderKeyValueTable(pairs []KeyValuePair, width int) string

RenderKeyValueTable renders a table of key-value pairs.

func RenderLabelValue

func RenderLabelValue(label, value string) string

RenderLabelValue renders a label-value pair.

func RenderLabeledDivider

func RenderLabeledDivider(label string, width int) string

RenderLabeledDivider renders a divider with a centered label.

func RenderPercentage

func RenderPercentage(value float64) string

RenderPercentage renders a percentage value with appropriate styling.

func RenderProgress

func RenderProgress(cfg ProgressConfig) string

RenderProgress renders a progress indicator. If ShowBar is true, renders a progress bar. Otherwise renders "current/total".

func RenderScrollablePanel

func RenderScrollablePanel(title string, lines []string, offset, visibleLines, width int) string

RenderScrollablePanel renders a panel that shows scrollable content.

func RenderStatus

func RenderStatus(cfg StatusConfig) string

RenderStatus renders a status indicator like "● RUNNING". Delegates to iostreams.StatusIndicator for style and symbol selection.

func RenderStatusBar

func RenderStatusBar(left, center, right string, width int) string

RenderStatusBar is a convenience function that renders a status bar.

func RenderStatusBarWithSections

func RenderStatusBarWithSections(sections []StatusBarSection, width int) string

RenderStatusBarWithSections renders a status bar with styled sections.

func RenderStepperBar

func RenderStepperBar(steps []Step, width int) string

RenderStepperBar renders a horizontal step indicator.

Completed steps show a checkmark icon with their title and optional value. Active steps show a filled circle icon with their title. Pending steps show an empty circle icon with their title. Skipped steps are hidden entirely.

Example output:

✓ Build Image: Yes  →  ◉ Flavor  →  ○ Submit

func RenderTable

func RenderTable(cfg TableConfig) string

RenderTable renders a simple table.

func RenderTag

func RenderTag(text string, render ...func(string) string) string

RenderTag renders a tag-like element. If no render function is provided, uses TagStyle.

func RenderTags

func RenderTags(tags []string, render ...func(string) string) string

RenderTags renders multiple tags inline. If no render function is provided, uses TagStyle.

func RunProgram

func RunProgram(ios *iostreams.IOStreams, model tea.Model, opts ...ProgramOption) (tea.Model, error)

RunProgram creates and runs a BubbleTea program with the given IOStreams. It returns the final model state after the program exits.

func TimerIndicator

func TimerIndicator(label string, value string) string

TimerIndicator creates a timer display for the status bar.

Types

type ConfirmField

type ConfirmField struct {
	ID     string
	Prompt string
	// contains filtered or unexported fields
}

ConfirmField is a standalone BubbleTea model for yes/no confirmation.

func NewConfirmField

func NewConfirmField(id, prompt string, defaultYes bool) ConfirmField

NewConfirmField creates a new ConfirmField with the given default value.

func (ConfirmField) BoolValue

func (f ConfirmField) BoolValue() bool

BoolValue returns the boolean value of the toggle.

func (ConfirmField) Init

func (f ConfirmField) Init() tea.Cmd

Init returns nil — no initial command is needed.

func (ConfirmField) IsConfirmed

func (f ConfirmField) IsConfirmed() bool

IsConfirmed returns true if the user has confirmed their choice.

func (ConfirmField) SetSize

func (f ConfirmField) SetSize(w, h int) ConfirmField

SetSize satisfies the wizard's updateAllFieldSizes contract. ConfirmField renders at a fixed layout, so width/height are unused.

func (ConfirmField) Update

func (f ConfirmField) Update(msg tea.Msg) (ConfirmField, tea.Cmd)

Update handles key messages. Left/Right/Tab toggle the value. Enter confirms. 'y' sets true, 'n' sets false.

func (ConfirmField) Value

func (f ConfirmField) Value() string

Value returns "yes" or "no" based on the current toggle state.

func (ConfirmField) View

func (f ConfirmField) View() string

View renders the confirm field with prompt and [ Yes ] / [ No ] toggle.

type DashboardConfig added in v0.1.4

type DashboardConfig struct {
	HelpText string // e.g., "q detach  ctrl+c stop"
}

DashboardConfig configures the generic dashboard.

type DashboardRenderer added in v0.1.4

type DashboardRenderer interface {
	// ProcessEvent handles a domain event received from the channel.
	ProcessEvent(ev any)
	// View renders the dashboard content for the given terminal width.
	// Should NOT include the help line — the framework handles that.
	View(cs *iostreams.ColorScheme, width int) string
}

DashboardRenderer controls the content of a channel-driven dashboard. Consumer packages implement this interface with domain-specific logic.

type DashboardResult added in v0.1.4

type DashboardResult struct {
	Err         error // display error only
	Detached    bool  // user pressed q/Esc
	Interrupted bool  // user pressed Ctrl+C
}

DashboardResult is returned when the dashboard exits.

func RunDashboard added in v0.1.4

func RunDashboard(ios *iostreams.IOStreams, renderer DashboardRenderer, cfg DashboardConfig, ch <-chan any) DashboardResult

RunDashboard runs a generic channel-driven dashboard. Events are read from ch and dispatched to renderer.ProcessEvent(). Returns when the channel is closed or the user presses q/Esc/Ctrl+C.

type FieldOption

type FieldOption struct {
	Label       string
	Description string
}

FieldOption represents a selectable option with a label and description.

type HeaderConfig

type HeaderConfig struct {
	Title     string
	Subtitle  string
	Timestamp string
	Width     int
}

HeaderConfig configures a header component.

type HelpConfig

type HelpConfig struct {
	Width     int
	ShowAll   bool // Show all bindings vs short help
	Separator string
}

HelpConfig configures the help bar component.

func DefaultHelpConfig

func DefaultHelpConfig() HelpConfig

DefaultHelpConfig returns sensible defaults for a help bar.

type HelpModel

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

HelpModel represents a help bar showing key bindings.

func NewHelp

func NewHelp(cfg HelpConfig) HelpModel

NewHelp creates a new help bar with the given configuration.

func (HelpModel) Bindings

func (m HelpModel) Bindings() []key.Binding

Bindings returns the current key bindings.

func (HelpModel) FullHelp

func (m HelpModel) FullHelp() string

FullHelp returns all bindings.

func (HelpModel) SetBindings

func (m HelpModel) SetBindings(bindings []key.Binding) HelpModel

SetBindings sets the key bindings to display.

func (HelpModel) SetSeparator

func (m HelpModel) SetSeparator(sep string) HelpModel

SetSeparator sets the separator between bindings.

func (HelpModel) SetShowAll

func (m HelpModel) SetShowAll(showAll bool) HelpModel

SetShowAll sets whether to show all bindings.

func (HelpModel) SetWidth

func (m HelpModel) SetWidth(width int) HelpModel

SetWidth sets the help bar width.

func (HelpModel) ShortHelp

func (m HelpModel) ShortHelp() string

ShortHelp returns a compact help string.

func (HelpModel) View

func (m HelpModel) View() string

View renders the help bar.

type HookResult

type HookResult struct {
	Continue bool   // false = quit execution
	Message  string // reason for quitting (only meaningful when Continue=false)
	Err      error  // hook's own failure (independent of Continue)
}

HookResult controls execution flow after a lifecycle hook fires.

type KeyMap

type KeyMap struct {
	Quit   key.Binding
	Up     key.Binding
	Down   key.Binding
	Left   key.Binding
	Right  key.Binding
	Enter  key.Binding
	Escape key.Binding
	Help   key.Binding
	Tab    key.Binding
}

KeyMap defines common key bindings used across TUI components.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default key bindings.

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
}

KeyValuePair represents a key-value pair for display.

type LifecycleHook

type LifecycleHook func(component, event string) HookResult

LifecycleHook is called at key moments during TUI component execution. component identifies the source (e.g., "progress"), event names the moment (e.g., "before_complete"). Implementations may block (for pausing) or return quickly (for logging). nil hooks are never called — components check before firing.

type ListConfig

type ListConfig struct {
	Width            int
	Height           int
	ShowDescriptions bool
	Wrap             bool
}

ListConfig configures a list component.

func DefaultListConfig

func DefaultListConfig() ListConfig

DefaultListConfig returns sensible defaults for a list.

type ListItem

type ListItem interface {
	// Title returns the main display text.
	Title() string
	// Description returns optional secondary text.
	Description() string
	// FilterValue returns the string used for filtering.
	FilterValue() string
}

ListItem represents an item that can be displayed in a list.

type ListModel

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

ListModel is a lightweight selectable list component.

func NewList

func NewList(cfg ListConfig) ListModel

NewList creates a new list with the given configuration.

func (ListModel) IsEmpty

func (m ListModel) IsEmpty() bool

IsEmpty returns true if the list has no items.

func (ListModel) Items

func (m ListModel) Items() []ListItem

Items returns all items in the list.

func (ListModel) Len

func (m ListModel) Len() int

Len returns the number of items.

func (ListModel) PageDown

func (m ListModel) PageDown() ListModel

PageDown moves selection down by one page.

func (ListModel) PageUp

func (m ListModel) PageUp() ListModel

PageUp moves selection up by one page.

func (ListModel) Select

func (m ListModel) Select(index int) ListModel

Select moves selection to a specific index.

func (ListModel) SelectFirst

func (m ListModel) SelectFirst() ListModel

SelectFirst moves selection to the first item.

func (ListModel) SelectLast

func (m ListModel) SelectLast() ListModel

SelectLast moves selection to the last item.

func (ListModel) SelectNext

func (m ListModel) SelectNext() ListModel

SelectNext moves selection to the next item.

func (ListModel) SelectPrev

func (m ListModel) SelectPrev() ListModel

SelectPrev moves selection to the previous item.

func (ListModel) SelectedIndex

func (m ListModel) SelectedIndex() int

SelectedIndex returns the index of the selected item.

func (ListModel) SelectedItem

func (m ListModel) SelectedItem() ListItem

SelectedItem returns the currently selected item, or nil if empty.

func (ListModel) SetHeight

func (m ListModel) SetHeight(height int) ListModel

SetHeight sets the list height.

func (ListModel) SetItems

func (m ListModel) SetItems(items []ListItem) ListModel

SetItems sets the list items.

func (ListModel) SetShowDescriptions

func (m ListModel) SetShowDescriptions(show bool) ListModel

SetShowDescriptions sets whether to show descriptions.

func (ListModel) SetWidth

func (m ListModel) SetWidth(width int) ListModel

SetWidth sets the list width.

func (ListModel) SetWrap

func (m ListModel) SetWrap(wrap bool) ListModel

SetWrap sets whether selection wraps around.

func (ListModel) Update

func (m ListModel) Update(msg tea.Msg) (ListModel, tea.Cmd)

Update handles key messages for navigation.

func (ListModel) View

func (m ListModel) View() string

View renders the list.

type PanelConfig

type PanelConfig struct {
	Title   string
	Width   int
	Height  int
	Focused bool
	Padding int
}

PanelConfig configures a panel component.

func DefaultPanelConfig

func DefaultPanelConfig() PanelConfig

DefaultPanelConfig returns sensible defaults for a panel.

type PanelGroup

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

PanelGroup manages a group of panels with focus handling.

func NewPanelGroup

func NewPanelGroup(panels ...PanelModel) PanelGroup

NewPanelGroup creates a new panel group.

func (PanelGroup) Add

func (g PanelGroup) Add(panel PanelModel) PanelGroup

Add adds a panel to the group.

func (PanelGroup) Focus

func (g PanelGroup) Focus(index int) PanelGroup

Focus sets focus to a specific panel index.

func (PanelGroup) FocusNext

func (g PanelGroup) FocusNext() PanelGroup

FocusNext moves focus to the next panel.

func (PanelGroup) FocusPrev

func (g PanelGroup) FocusPrev() PanelGroup

FocusPrev moves focus to the previous panel.

func (PanelGroup) FocusedIndex

func (g PanelGroup) FocusedIndex() int

FocusedIndex returns the index of the focused panel.

func (PanelGroup) FocusedPanel

func (g PanelGroup) FocusedPanel() PanelModel

FocusedPanel returns the currently focused panel.

func (PanelGroup) Panels

func (g PanelGroup) Panels() []PanelModel

Panels returns all panels in the group.

func (PanelGroup) RenderHorizontal

func (g PanelGroup) RenderHorizontal(gap int) string

RenderHorizontal renders panels in a horizontal row.

func (PanelGroup) RenderVertical

func (g PanelGroup) RenderVertical(gap int) string

RenderVertical renders panels in a vertical stack.

type PanelModel

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

PanelModel represents a bordered content container.

func NewPanel

func NewPanel(cfg PanelConfig) PanelModel

NewPanel creates a new panel with the given configuration.

func (PanelModel) Content

func (p PanelModel) Content() string

Content returns the panel's content.

func (PanelModel) Height

func (p PanelModel) Height() int

Height returns the panel's height.

func (PanelModel) IsFocused

func (p PanelModel) IsFocused() bool

IsFocused returns whether the panel is focused.

func (PanelModel) SetContent

func (p PanelModel) SetContent(content string) PanelModel

SetContent sets the panel's content.

func (PanelModel) SetFocused

func (p PanelModel) SetFocused(focused bool) PanelModel

SetFocused sets whether the panel is focused.

func (PanelModel) SetHeight

func (p PanelModel) SetHeight(height int) PanelModel

SetHeight sets the panel's height.

func (PanelModel) SetPadding

func (p PanelModel) SetPadding(padding int) PanelModel

SetPadding sets the panel's internal padding.

func (PanelModel) SetTitle

func (p PanelModel) SetTitle(title string) PanelModel

SetTitle sets the panel's title.

func (PanelModel) SetWidth

func (p PanelModel) SetWidth(width int) PanelModel

SetWidth sets the panel's width.

func (PanelModel) Title

func (p PanelModel) Title() string

Title returns the panel's title.

func (PanelModel) View

func (p PanelModel) View() string

View renders the panel.

func (PanelModel) Width

func (p PanelModel) Width() int

Width returns the panel's width.

type ProgramOption

type ProgramOption func(*programOptions)

ProgramOption configures a BubbleTea program.

func WithAltScreen

func WithAltScreen(enabled bool) ProgramOption

WithAltScreen enables or disables the alternate screen buffer.

func WithMouseMotion

func WithMouseMotion(enabled bool) ProgramOption

WithMouseMotion enables or disables mouse motion events.

type ProgressConfig

type ProgressConfig struct {
	Current int
	Total   int
	Width   int
	ShowBar bool
}

ProgressConfig configures a progress indicator.

type ProgressDisplayConfig

type ProgressDisplayConfig struct {
	Title    string // e.g., "Building"
	Subtitle string // e.g., image tag

	CompletionVerb string // Success summary verb (e.g., "Built", "Deployed"). Default: "Completed"

	MaxVisible int // per-stage child window size (default: 5)
	LogLines   int // per-step log buffer capacity (default: 3)

	// Callbacks — all optional. nil = passthrough / no-op.
	IsInternal     func(string) bool          // filter function (nil = show all)
	CleanName      func(string) string        // name cleaning (nil = passthrough)
	ParseGroup     func(string) string        // group/stage detection (nil = no groups)
	FormatDuration func(time.Duration) string // duration formatting (nil = default)

	// Lifecycle hook — called at key moments. nil = no-op.
	OnLifecycle LifecycleHook

	// AltScreen enables the alternate screen buffer for TTY mode.
	// When true, progress output is rendered in the alt screen and cleared
	// when the display finishes — useful for clean handoff to a container TTY.
	AltScreen bool
}

ProgressDisplayConfig configures the progress display. Domain-specific logic flows in through callbacks — the display itself has zero knowledge of what is being tracked.

type ProgressResult

type ProgressResult struct {
	Err error // only set if the progress display itself errors
}

ProgressResult contains the outcome of a progress display.

func RunProgress

func RunProgress(ios *iostreams.IOStreams, mode string, cfg ProgressDisplayConfig, ch <-chan ProgressStep) ProgressResult

RunProgress runs a progress display, consuming steps from ch until it is closed. It selects TTY (BubbleTea) or plain mode based on the terminal and mode setting. The mode parameter can be "auto", "plain", or "tty". Channel closure signals completion — the caller closes ch when done.

type ProgressStep

type ProgressStep struct {
	ID      string
	Name    string
	Status  ProgressStepStatus
	LogLine string
	Cached  bool
	Error   string
}

ProgressStep represents a single progress update from the pipeline. The caller sends these on a channel consumed by RunProgress.

type ProgressStepStatus

type ProgressStepStatus int

ProgressStepStatus represents the state of a progress step.

const (
	StepPending ProgressStepStatus = iota
	StepRunning
	StepComplete
	StepCached
	StepError
)

type SelectField

type SelectField struct {
	ID      string
	Prompt  string
	Options []FieldOption
	// contains filtered or unexported fields
}

SelectField is a standalone BubbleTea model for arrow-key selection. It wraps ListModel for navigation state but renders its own compact view with label + description on a single line.

func NewSelectField

func NewSelectField(id, prompt string, options []FieldOption, defaultIdx int) SelectField

NewSelectField creates a new SelectField with the given options. defaultIdx sets the initially selected option (clamped to valid range).

func (SelectField) Init

func (f SelectField) Init() tea.Cmd

Init returns nil — no initial command is needed.

func (SelectField) IsConfirmed

func (f SelectField) IsConfirmed() bool

IsConfirmed returns true if the user has confirmed their selection.

func (SelectField) SelectedIndex

func (f SelectField) SelectedIndex() int

SelectedIndex returns the index of the currently selected option.

func (SelectField) SetSize

func (f SelectField) SetSize(w, h int) SelectField

SetSize sets the width and height available for rendering.

func (SelectField) Update

func (f SelectField) Update(msg tea.Msg) (SelectField, tea.Cmd)

Update handles key messages. Up/Down delegate to the internal list. Enter confirms the selection and sends tea.Quit for standalone use.

func (SelectField) Value

func (f SelectField) Value() string

Value returns the label of the currently selected option.

func (SelectField) View

func (f SelectField) View() string

View renders the select field with prompt and compact option list. Each option shows label and description on one line:

> bookworm     Debian stable (Recommended)
  trixie       Debian testing

type SimpleListItem

type SimpleListItem struct {
	ItemTitle       string
	ItemDescription string
}

SimpleListItem is a basic implementation of ListItem.

func (SimpleListItem) Description

func (i SimpleListItem) Description() string

Description implements ListItem.

func (SimpleListItem) FilterValue

func (i SimpleListItem) FilterValue() string

FilterValue implements ListItem.

func (SimpleListItem) Title

func (i SimpleListItem) Title() string

Title implements ListItem.

type SpinnerModel

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

SpinnerModel is a wrapper around bubbles/spinner with clawker styling.

func NewDefaultSpinner

func NewDefaultSpinner(label string) SpinnerModel

NewDefaultSpinner creates a spinner with default settings.

func NewSpinner

func NewSpinner(spinnerType SpinnerType, label string) SpinnerModel

NewSpinner creates a new spinner with the specified type and label.

func (SpinnerModel) Init

func (m SpinnerModel) Init() tea.Cmd

Init initializes the spinner.

func (SpinnerModel) SetLabel

func (m SpinnerModel) SetLabel(label string) SpinnerModel

SetLabel updates the spinner's label.

func (SpinnerModel) SetSpinnerType

func (m SpinnerModel) SetSpinnerType(t SpinnerType) SpinnerModel

SetSpinnerType changes the spinner animation type.

func (SpinnerModel) Tick

func (m SpinnerModel) Tick() tea.Msg

Tick returns a command to tick the spinner.

func (SpinnerModel) Update

func (m SpinnerModel) Update(msg tea.Msg) (SpinnerModel, tea.Cmd)

Update handles messages for the spinner.

func (SpinnerModel) View

func (m SpinnerModel) View() string

View renders the spinner.

type SpinnerTickMsg

type SpinnerTickMsg = spinner.TickMsg

SpinnerTickMsg is sent when the spinner should update.

type SpinnerType

type SpinnerType int

SpinnerType defines the animation style for a spinner.

const (
	SpinnerDots SpinnerType = iota
	SpinnerLine
	SpinnerMiniDots
	SpinnerJump
	SpinnerPulse
	SpinnerPoints
	SpinnerGlobe
	SpinnerMoon
	SpinnerMonkey
)

type StatusBarModel

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

StatusBarModel represents a single-line status bar with left/center/right sections.

func NewStatusBar

func NewStatusBar(width int) StatusBarModel

NewStatusBar creates a new status bar with the given width.

func (StatusBarModel) Center

func (m StatusBarModel) Center() string

Center returns the center section content.

func (StatusBarModel) Left

func (m StatusBarModel) Left() string

Left returns the left section content.

func (StatusBarModel) Right

func (m StatusBarModel) Right() string

Right returns the right section content.

func (StatusBarModel) SetCenter

func (m StatusBarModel) SetCenter(s string) StatusBarModel

SetCenter sets the center section content.

func (StatusBarModel) SetLeft

func (m StatusBarModel) SetLeft(s string) StatusBarModel

SetLeft sets the left section content.

func (StatusBarModel) SetRight

func (m StatusBarModel) SetRight(s string) StatusBarModel

SetRight sets the right section content.

func (StatusBarModel) SetWidth

func (m StatusBarModel) SetWidth(width int) StatusBarModel

SetWidth sets the status bar width.

func (StatusBarModel) View

func (m StatusBarModel) View() string

View renders the status bar.

func (StatusBarModel) Width

func (m StatusBarModel) Width() int

Width returns the status bar width.

type StatusBarSection

type StatusBarSection struct {
	Content string
	Render  func(string) string
}

StatusBarSection represents a styled section of the status bar.

type StatusConfig

type StatusConfig struct {
	Status string
	Label  string
}

StatusConfig configures a status indicator.

type Step

type Step struct {
	Title string // Short label for the bar
	Value string // Displayed next to completed steps (e.g., "bookworm")
	State StepState
}

Step represents a single step in a stepper bar.

type StepState

type StepState int

StepState represents the state of a step in a stepper bar.

const (
	// StepPendingState indicates the step has not been started.
	StepPendingState StepState = iota
	// StepActiveState indicates the step is currently active.
	StepActiveState
	// StepCompleteState indicates the step has been completed.
	StepCompleteState
	// StepSkippedState indicates the step was skipped (hidden from display).
	StepSkippedState
)

func (StepState) String

func (s StepState) String() string

String returns a human-readable representation of the step state.

type TUI

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

TUI provides the interactive presentation layer. Constructed once via Factory; hooks registered separately after construction. This enables pointer-sharing: commands capture *TUI eagerly at NewCmd time, while hooks are registered later (e.g., in PersistentPreRunE after flag parsing).

func NewTUI

func NewTUI(ios *iostreams.IOStreams) *TUI

NewTUI creates a TUI bound to the given IOStreams.

func (*TUI) IOStreams

func (t *TUI) IOStreams() *iostreams.IOStreams

IOStreams returns the underlying IOStreams for callers that need direct access.

func (*TUI) NewTable

func (t *TUI) NewTable(headers ...string) *TablePrinter

NewTable creates a TablePrinter bound to this TUI's IOStreams.

func (*TUI) RegisterHooks

func (t *TUI) RegisterHooks(hooks ...LifecycleHook)

RegisterHooks appends one or more lifecycle hooks. Hooks fire in registration order; the first non-continue result short-circuits.

func (*TUI) RunProgress

func (t *TUI) RunProgress(mode string, cfg ProgressDisplayConfig, ch <-chan ProgressStep) ProgressResult

RunProgress displays a multi-step progress view, delegating to the package-level RunProgress function. Registered hooks are injected into cfg.OnLifecycle if the caller has not already set one.

func (*TUI) RunWizard

func (t *TUI) RunWizard(fields []WizardField) (WizardResult, error)

RunWizard runs a multi-step wizard using the given field definitions. Returns the collected values and whether the wizard was submitted (vs cancelled).

type TableConfig

type TableConfig struct {
	Headers   []string
	Rows      [][]string
	ColWidths []int
	Width     int
}

RenderTable renders a simple table with headers and rows.

type TablePrinter

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

TablePrinter renders tabular data with TTY-aware styling. In styled mode (TTY + color), delegates to iostreams.RenderStyledTable (lipgloss/table). In plain mode (non-TTY/piped), uses text/tabwriter for machine-friendly output.

func (*TablePrinter) AddRow

func (tp *TablePrinter) AddRow(cols ...string)

AddRow appends a data row. Missing columns are padded with empty strings; extra columns beyond the header count are discarded.

func (*TablePrinter) Len

func (tp *TablePrinter) Len() int

Len returns the number of data rows (excluding the header).

func (*TablePrinter) Render

func (tp *TablePrinter) Render() error

Render writes the table to ios.Out. Returns nil if there are no headers.

func (*TablePrinter) WithCellStyle

func (tp *TablePrinter) WithCellStyle(fn func(string) string) *TablePrinter

WithCellStyle overrides the default cell style. The function receives cell text and returns styled text. Pass nil to use the default (plain with padding).

func (*TablePrinter) WithHeaderStyle

func (tp *TablePrinter) WithHeaderStyle(fn func(string) string) *TablePrinter

WithHeaderStyle overrides the header row style. The function receives cell text and returns styled text. Pass nil to use the default (TableHeaderStyle).

func (*TablePrinter) WithPrimaryStyle

func (tp *TablePrinter) WithPrimaryStyle(fn func(string) string) *TablePrinter

WithPrimaryStyle overrides the first-column style. The function receives cell text and returns styled text. Pass nil to use the default (TablePrimaryColumnStyle).

type TextField

type TextField struct {
	ID     string
	Prompt string
	// contains filtered or unexported fields
}

TextField is a standalone BubbleTea model for text input. It wraps the bubbles textinput component with validation support.

func NewTextField

func NewTextField(id, prompt string, opts ...TextFieldOption) TextField

NewTextField creates a new TextField with the given options.

func (TextField) Err

func (f TextField) Err() string

Err returns the current validation error message, or empty string if none.

func (TextField) Init

func (f TextField) Init() tea.Cmd

Init returns the textinput blink command to start cursor blinking.

func (TextField) IsConfirmed

func (f TextField) IsConfirmed() bool

IsConfirmed returns true if the user has confirmed the input.

func (TextField) SetSize

func (f TextField) SetSize(w, h int) TextField

SetSize sets the width available for the text input.

func (TextField) Update

func (f TextField) Update(msg tea.Msg) (TextField, tea.Cmd)

Update handles key messages. Enter validates and confirms. All other keys are delegated to the underlying textinput.

func (TextField) Value

func (f TextField) Value() string

Value returns the current text input value.

func (TextField) View

func (f TextField) View() string

View renders the text field with prompt, input, and optional error message.

type TextFieldOption

type TextFieldOption func(*TextField)

TextFieldOption is a functional option for configuring a TextField.

func WithDefault

func WithDefault(s string) TextFieldOption

WithDefault sets the initial value of the text input.

func WithPlaceholder

func WithPlaceholder(s string) TextFieldOption

WithPlaceholder sets the placeholder text shown when the input is empty.

func WithRequired

func WithRequired() TextFieldOption

WithRequired marks the field as required — an empty value is rejected on Enter.

func WithValidator

func WithValidator(fn func(string) error) TextFieldOption

WithValidator sets a validation function called on Enter. If the function returns an error, the field displays it and does not confirm.

type ViewportConfig

type ViewportConfig struct {
	Width   int
	Height  int
	Title   string
	Content string
}

ViewportConfig configures a viewport component.

type ViewportModel

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

ViewportModel wraps a bubbles viewport with consistent styling. It provides scrollable content within a bordered panel.

func NewViewport

func NewViewport(cfg ViewportConfig) ViewportModel

NewViewport creates a new viewport with the given configuration.

func (ViewportModel) AtBottom

func (v ViewportModel) AtBottom() bool

AtBottom returns true if the viewport is scrolled to the bottom.

func (ViewportModel) AtTop

func (v ViewportModel) AtTop() bool

AtTop returns true if the viewport is scrolled to the top.

func (ViewportModel) Height

func (v ViewportModel) Height() int

Height returns the viewport height.

func (ViewportModel) Init

func (v ViewportModel) Init() tea.Cmd

Init implements tea.Model.

func (ViewportModel) ScrollPercent

func (v ViewportModel) ScrollPercent() float64

ScrollPercent returns the scroll position as a percentage (0.0 to 1.0).

func (ViewportModel) ScrollToBottom

func (v ViewportModel) ScrollToBottom() ViewportModel

ScrollToBottom scrolls to the bottom of the content.

func (ViewportModel) ScrollToTop

func (v ViewportModel) ScrollToTop() ViewportModel

ScrollToTop scrolls to the top of the content.

func (ViewportModel) SetContent

func (v ViewportModel) SetContent(s string) ViewportModel

SetContent sets the viewport content.

func (ViewportModel) SetSize

func (v ViewportModel) SetSize(width, height int) ViewportModel

SetSize sets the viewport dimensions.

func (ViewportModel) SetTitle

func (v ViewportModel) SetTitle(title string) ViewportModel

SetTitle sets the viewport title.

func (ViewportModel) Title

func (v ViewportModel) Title() string

Title returns the viewport title.

func (ViewportModel) Update

func (v ViewportModel) Update(msg tea.Msg) (ViewportModel, tea.Cmd)

Update implements tea.Model.

func (ViewportModel) View

func (v ViewportModel) View() string

View renders the viewport.

func (ViewportModel) Width

func (v ViewportModel) Width() int

Width returns the viewport width.

type WizardField

type WizardField struct {
	ID     string
	Title  string // StepperBar label
	Prompt string // Question text
	Kind   WizardFieldKind

	// Select-specific fields.
	Options    []FieldOption
	DefaultIdx int

	// Text-specific fields.
	Placeholder string
	Default     string
	Validator   func(string) error
	Required    bool

	// Confirm-specific fields.
	DefaultYes bool

	// Conditional: skip this step when predicate returns true.
	SkipIf func(WizardValues) bool
}

WizardField defines a single step in the wizard.

type WizardFieldKind

type WizardFieldKind int

WizardFieldKind identifies the type of field in a wizard step.

const (
	// FieldSelect is an arrow-key selection field.
	FieldSelect WizardFieldKind = iota
	// FieldText is a text input field.
	FieldText
	// FieldConfirm is a yes/no confirmation field.
	FieldConfirm
)

func (WizardFieldKind) String

func (k WizardFieldKind) String() string

String returns a debug-friendly name for WizardFieldKind.

type WizardResult

type WizardResult struct {
	Values    WizardValues
	Submitted bool
}

WizardResult is returned by RunWizard.

type WizardValues

type WizardValues map[string]string

WizardValues is a map of field ID to string value.

Jump to

Keyboard shortcuts

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