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

ui

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source

Variables

View Source
var (
	StyleTitle       = lipgloss.NewStyle().Foreground(lavender).Bold(true)
	StyleSelector    = lipgloss.NewStyle().Foreground(rose)
	StyleSelected    = lipgloss.NewStyle().Foreground(mint)
	StyleDescription = lipgloss.NewStyle().Foreground(lipgloss.Color("241"))
	StyleSeparator   = lipgloss.NewStyle().Foreground(lavender)
	StyleHint        = lipgloss.NewStyle().Faint(true)
	StyleError       = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF6B6B"))

	StyleSafetySafe        = lipgloss.NewStyle().Foreground(safetyGreen)
	StyleSafetyCautious    = lipgloss.NewStyle().Foreground(safetyYellow)
	StyleSafetyRisky       = lipgloss.NewStyle().Foreground(safetyOrange)
	StyleSafetyDestructive = lipgloss.NewStyle().Foreground(safetyRed)
	StyleWarning           = lipgloss.NewStyle().Foreground(safetyRed).Bold(true)

	AISpinner = spinner.Spinner{
		Frames: []string{
			lipgloss.NewStyle().Foreground(lavender).Render(AILogo),
			lipgloss.NewStyle().Foreground(rose).Render(AILogo),
			lipgloss.NewStyle().Foreground(mint).Render(AILogo),
			lipgloss.NewStyle().Foreground(sky).Render(AILogo),
		},
		FPS: 200 * time.Millisecond,
	}
)
View Source
var ErrAborted = errors.New("user aborted")

Functions

func NewTable

func NewTable(w io.Writer) *tabwriter.Writer

NewTable returns a tabwriter.Writer with project-wide consistent settings.

func RenderFrame

func RenderFrame(title string, content string, hints []Hint, width int) string

func RunConfirm

func RunConfirm(opts RunOptions, spec ConfirmSpec) (bool, error)

func RunFlow

func RunFlow[T any](flow Flow, opts RunOptions) (T, error)

func RunForm

func RunForm(opts RunOptions, spec FormSpec) (map[string]string, error)

func RunInput

func RunInput(opts RunOptions, spec InputSpec) (string, error)

func RunMultiSelect

func RunMultiSelect[T comparable](opts RunOptions, spec MultiSelectSpec[T]) ([]T, error)

func RunSelect

func RunSelect[T comparable](opts RunOptions, spec SelectSpec[T]) (T, error)

func SafetyStyle

func SafetyStyle(level SafetyLevel) lipgloss.Style

func Spinner

func Spinner(w io.Writer, label string) (stop func())

Spinner starts a braille spinner on w with the given label. Call the returned stop func when the operation completes; it clears the line. stop() blocks until the line is cleared — no race with subsequent renders.

func TermWidth

func TermWidth() int

Types

type ActionModel

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

func NewActionStep

func NewActionStep(spec ActionSpec) *ActionModel

func (*ActionModel) FooterHints

func (m *ActionModel) FooterHints() []Hint

func (*ActionModel) Init

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

func (*ActionModel) SetSize

func (m *ActionModel) SetSize(width, _ int)

func (*ActionModel) Title

func (m *ActionModel) Title() string

func (*ActionModel) Update

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

func (*ActionModel) View

func (m *ActionModel) View() string

type ActionResult

type ActionResult string
const (
	ActionApprove  ActionResult = "approve"
	ActionReject   ActionResult = "reject"
	ActionModify   ActionResult = "modify"
	ActionReprompt ActionResult = "reprompt"
)

func RunAction

func RunAction(opts RunOptions, spec ActionSpec) (ActionResult, error)

type ActionSpec

type ActionSpec struct {
	Command   string
	Safety    SafetyLevel
	Breakdown string
}

type App

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

func (*App) Init

func (a *App) Init() tea.Cmd

func (*App) Update

func (a *App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*App) View

func (a *App) View() string

type ConfirmModel

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

func NewConfirmStep

func NewConfirmStep(spec ConfirmSpec) *ConfirmModel

func (*ConfirmModel) FooterHints

func (m *ConfirmModel) FooterHints() []Hint

func (*ConfirmModel) Init

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

func (*ConfirmModel) SetSize

func (m *ConfirmModel) SetSize(width, _ int)

func (*ConfirmModel) Title

func (m *ConfirmModel) Title() string

func (*ConfirmModel) Update

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

func (*ConfirmModel) View

func (m *ConfirmModel) View() string

type ConfirmSpec

type ConfirmSpec struct {
	Title   string
	Default bool
}

type Flow

type Flow interface {
	Start() Step
	Next(result any) (Step, bool, error)
}

type FormModel

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

func NewFormStep

func NewFormStep(spec FormSpec) *FormModel

func (*FormModel) FooterHints

func (m *FormModel) FooterHints() []Hint

func (*FormModel) Init

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

func (*FormModel) SetSize

func (m *FormModel) SetSize(width, _ int)

func (*FormModel) Title

func (m *FormModel) Title() string

func (*FormModel) Update

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

func (*FormModel) View

func (m *FormModel) View() string

type FormSpec

type FormSpec struct {
	Title  string
	Fields []InputField
}

type Hint

type Hint struct {
	Key  string
	Desc string
}

type InputField

type InputField struct {
	Key         string
	Label       string
	Placeholder string
	Default     string
	Password    bool
	Validate    func(string) error
}

type InputModel

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

func NewInputStep

func NewInputStep(spec InputSpec) *InputModel

func (*InputModel) FooterHints

func (m *InputModel) FooterHints() []Hint

func (*InputModel) Init

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

func (*InputModel) SetSize

func (m *InputModel) SetSize(width, _ int)

func (*InputModel) Title

func (m *InputModel) Title() string

func (*InputModel) Update

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

func (*InputModel) View

func (m *InputModel) View() string

type InputSpec

type InputSpec struct {
	Title       string
	Placeholder string
	Default     string
	Password    bool
	Validate    func(string) error
}

type LoadingModel

type LoadingModel[T any] struct {
	// contains filtered or unexported fields
}

func NewLoading

func NewLoading[T any](spec LoadingSpec[T]) *LoadingModel[T]

func (*LoadingModel[T]) FooterHints

func (m *LoadingModel[T]) FooterHints() []Hint

func (*LoadingModel[T]) Init

func (m *LoadingModel[T]) Init() tea.Cmd

func (*LoadingModel[T]) SetSize

func (m *LoadingModel[T]) SetSize(width, _ int)

func (*LoadingModel[T]) Title

func (m *LoadingModel[T]) Title() string

func (*LoadingModel[T]) Update

func (m *LoadingModel[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*LoadingModel[T]) View

func (m *LoadingModel[T]) View() string

type LoadingSpec

type LoadingSpec[T any] struct {
	Title         string
	Label         string
	Task          func() (T, error)
	CustomSpinner *spinner.Spinner
}

type MultiSelectModel

type MultiSelectModel[T comparable] struct {
	// contains filtered or unexported fields
}

func NewMultiSelectStep

func NewMultiSelectStep[T comparable](spec MultiSelectSpec[T]) *MultiSelectModel[T]

func (*MultiSelectModel[T]) FooterHints

func (m *MultiSelectModel[T]) FooterHints() []Hint

func (*MultiSelectModel[T]) Init

func (m *MultiSelectModel[T]) Init() tea.Cmd

func (*MultiSelectModel[T]) SetSize

func (m *MultiSelectModel[T]) SetSize(width, height int)

func (*MultiSelectModel[T]) Title

func (m *MultiSelectModel[T]) Title() string

func (*MultiSelectModel[T]) Update

func (m *MultiSelectModel[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*MultiSelectModel[T]) View

func (m *MultiSelectModel[T]) View() string

type MultiSelectSpec

type MultiSelectSpec[T comparable] struct {
	Title    string
	Options  []Option[T]
	Defaults []T
	Height   int
}

type Option

type Option[T comparable] struct {
	Label       string
	Description string
	Value       T
	Loading     bool
}

type OptionUpdateMsg

type OptionUpdateMsg struct {
	Index       int
	Description string
}

type RunOptions

type RunOptions struct {
	In  io.Reader
	Out io.Writer
}

type SafetyLevel

type SafetyLevel string
const (
	SafetySafe        SafetyLevel = "safe"
	SafetyCautious    SafetyLevel = "cautious"
	SafetyRisky       SafetyLevel = "risky"
	SafetyDestructive SafetyLevel = "destructive"
)

type SelectModel

type SelectModel[T comparable] struct {
	// contains filtered or unexported fields
}

func NewSelectStep

func NewSelectStep[T comparable](spec SelectSpec[T]) *SelectModel[T]

func (*SelectModel[T]) FooterHints

func (m *SelectModel[T]) FooterHints() []Hint

func (*SelectModel[T]) Init

func (m *SelectModel[T]) Init() tea.Cmd

func (*SelectModel[T]) SetSize

func (m *SelectModel[T]) SetSize(width, height int)

func (*SelectModel[T]) Title

func (m *SelectModel[T]) Title() string

func (*SelectModel[T]) Update

func (m *SelectModel[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*SelectModel[T]) View

func (m *SelectModel[T]) View() string

type SelectSpec

type SelectSpec[T comparable] struct {
	Title   string
	Options []Option[T]
	Height  int
	InitCmd tea.Cmd
}

type Step

type Step interface {
	tea.Model
	Title() string
	FooterHints() []Hint
	SetSize(width, height int)
}

Jump to

Keyboard shortcuts

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