ui

package
v0.0.0-...-a5a3bde Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ui provides UI components for interactive flows

Package ui provides UI components for interactive flows

Index

Constants

View Source
const (
	// ProgressStepCount is the default number of steps in progress tracking
	ProgressStepCount = 4

	// TableMaxWidth is the maximum width for table displays
	TableMaxWidth = 120

	// SpinnerRefreshRate is how often to refresh spinner animations
	SpinnerRefreshRate = 100 * time.Millisecond
)

UI and Display

View Source
const (
	ColorBrightCyan  = "14"
	ColorRed         = "9"
	ColorYellow      = "11"
	ColorGreen       = "10"
	ColorGray        = "7"
	ColorBrightGray  = "8"
	ColorBrightWhite = "15"
)

Color constants for consistent styling

Variables

This section is empty.

Functions

func CollectWithForm

func CollectWithForm(form *huh.Form, errorMsg string) error

CollectWithForm is a generic form collection helper to reduce code duplication

func CreateConfirmForm

func CreateConfirmForm(title, description, affirmative, negative string, value *bool) *huh.Form

CreateConfirmForm creates a confirm form

func CreateConfirmGroup

func CreateConfirmGroup(title, description, affirmative, negative string, value *bool) *huh.Group

CreateConfirmGroup creates a confirm group for a form

func CreateInputForm

func CreateInputForm(title, placeholder, description string, validator func(string) error, value *string) *huh.Form

CreateInputForm creates an input form

func CreateInputGroup

func CreateInputGroup(title, placeholder, description string, validator func(string) error, value *string) *huh.Group

CreateInputGroup creates an input group for a form

func CreateMultiSelectForm

func CreateMultiSelectForm(title, description string, options []huh.Option[string], value *[]string) *huh.Form

CreateMultiSelectForm creates a multi-select form

func CreateNoteForm

func CreateNoteForm(title, description string) *huh.Form

CreateNoteForm creates a note form

func CreateNoteGroup

func CreateNoteGroup(title, description string) *huh.Group

CreateNoteGroup creates a note group for a form

func CreateSelectForm

func CreateSelectForm(title, description string, options []huh.Option[string], value *string) *huh.Form

CreateSelectForm creates a select form

func CreateSelectGroup

func CreateSelectGroup(title, description string, options []huh.Option[string], value *string) *huh.Group

CreateSelectGroup creates a select group for a form

func GetEnvironmentStyle

func GetEnvironmentStyle(environment string) lipgloss.Style

Common style functions for reuse

func GetStatusStyle

func GetStatusStyle(status string) lipgloss.Style

func IsTerminal

func IsTerminal() bool

isTerminal checks if the output is going to a terminal

Types

type Column

type Column struct {
	Title     string
	Key       string
	Width     int
	MinWidth  int
	MaxWidth  int
	Truncate  bool
	StyleFunc func(value string) lipgloss.Style
	Condition bool
}

Column represents a table column definition

type ProgressTracker

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

ProgressTracker helps track steps during interactive flows

func NewProgressTracker

func NewProgressTracker() *ProgressTracker

NewProgressTracker creates a new progress tracker with the default steps

func (*ProgressTracker) GetCurrentStep

func (pt *ProgressTracker) GetCurrentStep() string

GetCurrentStep returns the current step

func (*ProgressTracker) NextStep

func (pt *ProgressTracker) NextStep()

NextStep increments the current step

type Row

type Row map[string]string

Row represents a table row with data

type Table

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

Table represents a configurable table renderer

func NewTable

func NewTable() *Table

NewTable creates a new table with default styling

func (*Table) Print

func (t *Table) Print()

Print renders and prints the table

func (*Table) Render

func (t *Table) Render() string

Render renders the table as a string

func (*Table) SetColumns

func (t *Table) SetColumns(columns []Column) *Table

SetColumns sets the table columns

func (*Table) SetHeaderStyle

func (t *Table) SetHeaderStyle(style lipgloss.Style) *Table

SetHeaderStyle sets the header styling

func (*Table) SetMaxWidth

func (t *Table) SetMaxWidth(width int) *Table

SetMaxWidth sets the maximum table width

func (*Table) SetRows

func (t *Table) SetRows(rows []Row) *Table

SetRows sets the table data

func (*Table) SetSeparatorStyle

func (t *Table) SetSeparatorStyle(style lipgloss.Style) *Table

SetSeparatorStyle sets the separator line styling

Jump to

Keyboard shortcuts

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