Documentation
¶
Overview ¶
Package output provides CLI output utilities with color support.
Package output provides CLI output utilities with color support.
Index ¶
- Variables
- func NoColor(cfg *config.Config, explicitNoColor bool) bool
- func VisibleWidth(s string) int
- type Printer
- func (p *Printer) Error(format string, args ...interface{})
- func (p *Printer) Info(format string, args ...interface{})
- func (p *Printer) NoColor() bool
- func (p *Printer) Print(format string, args ...interface{})
- func (p *Printer) Printf(format string, args ...interface{})
- func (p *Printer) Println(args ...interface{})
- func (p *Printer) SetErrorOutput(w io.Writer)
- func (p *Printer) SetOutput(w io.Writer)
- func (p *Printer) Styles() *Styles
- func (p *Printer) Success(format string, args ...interface{})
- func (p *Printer) Warning(format string, args ...interface{})
- type Spinner
- type SpinnerOption
- type Styles
- func (s *Styles) ErrorIcon() string
- func (s *Styles) FormatAgentName(name string) string
- func (s *Styles) FormatBadge(text, variant string) string
- func (s *Styles) FormatHeader(text string) string
- func (s *Styles) FormatMethod(method string) string
- func (s *Styles) FormatStatus(status string) string
- func (s *Styles) FormatVersion(version string, hasUpdate bool) string
- func (s *Styles) InfoIcon() string
- func (s *Styles) InstalledIcon() string
- func (s *Styles) NotInstalledIcon() string
- func (s *Styles) SuccessIcon() string
- func (s *Styles) UpdateIcon() string
- func (s *Styles) WarningIcon() string
- type Table
Constants ¶
This section is empty.
Variables ¶
var SpinnerFrames = struct { Dots []string Line []string Arrow []string Pulse []string Binary []string Circle []string }{ Dots: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}, Line: []string{"-", "\\", "|", "/"}, Arrow: []string{"←", "↖", "↑", "↗", "→", "↘", "↓", "↙"}, Pulse: []string{"◐", "◓", "◑", "◒"}, Binary: []string{"010010", "001001", "100100", "010010", "001001"}, Circle: []string{"◜", "◠", "◝", "◞", "◡", "◟"}, }
SpinnerFrames contains predefined spinner frame sets.
Functions ¶
func NoColor ¶ added in v1.1.0
NoColor returns the single source of truth for "should output be colorless?" given a config and an explicit flag. Callers should use this helper instead of reading cfg.UI.UseColors, NO_COLOR, and --no-color separately, which historically drifted between call sites.
Order of precedence (any -> true):
- NO_COLOR environment variable is set to a non-empty value
- --no-color flag (caller passes this as explicitNoColor)
- cfg.UI.UseColors is false
func VisibleWidth ¶
VisibleWidth returns the visible width of a string (excluding ANSI codes)
Types ¶
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer handles colorized output for CLI commands.
func NewPrinter ¶
NewPrinter creates a new Printer instance.
func (*Printer) NoColor ¶ added in v1.1.0
NoColor returns true if the printer is configured to render without color. Use this to propagate the same setting to spinners and other output helpers, avoiding the need to re-derive from env / config at each call site.
func (*Printer) Println ¶
func (p *Printer) Println(args ...interface{})
Println prints a message with a newline.
func (*Printer) SetErrorOutput ¶
SetErrorOutput sets the error output writer.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner displays a loading animation in the terminal.
func NewSpinner ¶
func NewSpinner(opts ...SpinnerOption) *Spinner
NewSpinner creates a new spinner instance.
func (*Spinner) Start ¶
func (s *Spinner) Start()
Start starts the spinner animation.
When the output is not a TTY (e.g. piped, redirected, captured in CI), Start is a no-op. This prevents ANSI escape sequences from corrupting downstream consumers.
func (*Spinner) Stop ¶
func (s *Spinner) Stop()
Stop stops the spinner animation.
When the spinner never started (non-TTY path), Stop is a no-op and the clear-line escape sequence is not emitted.
func (*Spinner) UpdateMessage ¶
UpdateMessage updates the spinner message while it's running.
type SpinnerOption ¶
type SpinnerOption func(*Spinner)
SpinnerOption is a functional option for configuring a Spinner.
func WithFrames ¶
func WithFrames(frames []string) SpinnerOption
WithFrames sets custom spinner frames.
func WithInterval ¶
func WithInterval(interval time.Duration) SpinnerOption
WithInterval sets the spinner animation interval.
func WithOutput ¶
func WithOutput(w io.Writer) SpinnerOption
WithOutput sets the spinner output writer.
type Styles ¶
type Styles struct {
// Colors
Purple lipgloss.Color
Green lipgloss.Color
Orange lipgloss.Color
Red lipgloss.Color
Cyan lipgloss.Color
Yellow lipgloss.Color
Gray lipgloss.Color
White lipgloss.Color
// Text styles
Success lipgloss.Style
Error lipgloss.Style
Warning lipgloss.Style
Info lipgloss.Style
Muted lipgloss.Style
Bold lipgloss.Style
Header lipgloss.Style
// Status styles
StatusInstalled lipgloss.Style
StatusUpdate lipgloss.Style
StatusNotFound lipgloss.Style
StatusError lipgloss.Style
// Badge styles
Badge lipgloss.Style
BadgeSuccess lipgloss.Style
BadgeWarning lipgloss.Style
BadgeError lipgloss.Style
BadgeInfo lipgloss.Style
// contains filtered or unexported fields
}
Styles holds the visual styles for CLI output.
func (*Styles) FormatAgentName ¶
FormatAgentName formats an agent name.
func (*Styles) FormatBadge ¶
FormatBadge formats a badge with the given variant.
func (*Styles) FormatHeader ¶
FormatHeader formats a table header.
func (*Styles) FormatMethod ¶
FormatMethod formats an installation method.
func (*Styles) FormatStatus ¶
FormatStatus formats a status indicator with color.
func (*Styles) FormatVersion ¶
FormatVersion formats a version string with color.
func (*Styles) InstalledIcon ¶
InstalledIcon returns the installed icon.
func (*Styles) NotInstalledIcon ¶
NotInstalledIcon returns the not installed icon.
func (*Styles) SuccessIcon ¶
SuccessIcon returns the success icon.
func (*Styles) UpdateIcon ¶
UpdateIcon returns the update available icon.
func (*Styles) WarningIcon ¶
WarningIcon returns the warning icon.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table handles aligned table output with ANSI color support.
func (*Table) SetHeaders ¶
SetHeaders sets the table headers.
func (*Table) SetPadding ¶
SetPadding sets the column padding.