Documentation
¶
Overview ¶
Package ui provides terminal output helpers styled with charmbracelet/lipgloss. Color palette and patterns match the tapes CLI (pkg/cliui).
Index ¶
- Variables
- func Bold(format string, args ...interface{})
- func Box(w io.Writer, content string, borderColor lipgloss.Color)
- func Confirm(format string, args ...interface{}) bool
- func Error(format string, args ...interface{})
- func FormatDuration(d time.Duration) string
- func Info(format string, args ...interface{})
- func Label(label, value string) string
- func Mark(err error) string
- func StateStyle(state string) lipgloss.Style
- func Status(format string, args ...interface{})
- func Step(w io.Writer, msg string, fn func() error) error
- func Success(format string, args ...interface{})
- func Warn(format string, args ...interface{})
- type Spinner
- type Table
Constants ¶
This section is empty.
Variables ¶
var ( GreenColor = lipgloss.Color("82") RedColor = lipgloss.Color("196") CyanColor = lipgloss.Color("39") YellowColor = lipgloss.Color("226") GrayColor = lipgloss.Color("245") DimColor = lipgloss.Color("241") LightColor = lipgloss.Color("252") )
Color palette (ANSI 256, matching tapes/pkg/cliui).
var ( SuccessMark = lipgloss.NewStyle().Foreground(GreenColor).Render("\u2713") FailMark = lipgloss.NewStyle().Foreground(RedColor).Render("\u2717") StepStyle = lipgloss.NewStyle().Foreground(GrayColor) NameStyle = lipgloss.NewStyle().Foreground(GreenColor).Bold(true) DimStyle = lipgloss.NewStyle().Foreground(DimColor) HashStyle = lipgloss.NewStyle().Foreground(CyanColor) HeaderStyle = lipgloss.NewStyle().Foreground(LightColor).Bold(true) )
Shared styles for CLI output formatting.
Functions ¶
func Box ¶
Box renders content inside a rounded-border box to the given writer. The box fits to content width with 1-line vertical and 2-char horizontal padding, matching the gum style --border rounded --padding "1 2" pattern.
func Confirm ¶
Confirm prompts the user with an interactive yes/no confirmation using charmbracelet/huh. Returns true if the user confirms, false otherwise. Defaults to "no" if the user presses enter without selecting.
func FormatDuration ¶
FormatDuration formats a duration for display (e.g. "12ms" or "3.2s").
func Info ¶
func Info(format string, args ...interface{})
Info prints a dim indented detail line to stderr.
func StateStyle ¶
StateStyle returns a lipgloss style for color-coding sandbox states.
func Status ¶
func Status(format string, args ...interface{})
Status prints a cyan status message to stderr.
func Step ¶
Step prints an animated spinner while fn runs, then replaces it with a checkmark or X mark and elapsed time. Matches tapes cliui.Step(). When the writer is not a TTY (piped output, CI), the spinner is skipped and only the final result line is printed.
Types ¶
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner provides a standalone animated progress indicator for long operations where Step() is not suitable (e.g. the daemon serve loop).
func NewSpinner ¶
NewSpinner creates a new spinner with the given message.
func (*Spinner) Start ¶
func (s *Spinner) Start()
Start begins the spinner animation in a background goroutine.
func (*Spinner) Stop ¶
func (s *Spinner) Stop()
Stop halts the spinner animation and clears the line.
func (*Spinner) StopWithMessage ¶
StopWithMessage halts the spinner and prints a final message.