Documentation
¶
Overview ¶
Package printer provides rich terminal styling for CLI output.
This package uses lipgloss for consistent, attractive console output across the sley CLI. It provides both render functions (returning styled strings) and print functions (outputting to stdout).
Styling Functions ¶
Render functions return styled strings without printing:
styled := printer.Success("Operation completed")
styled := printer.Error("Something went wrong")
styled := printer.Warning("Deprecated feature")
styled := printer.Info("Processing...")
styled := printer.Bold("Important")
styled := printer.Faint("Secondary info")
Print Functions ¶
Print functions output styled text to stdout with a newline:
printer.PrintSuccess("Version bumped to 1.2.3")
printer.PrintError("Failed to read config")
printer.PrintWarning("No changelog entries found")
printer.PrintInfo("Checking dependencies...")
Badges ¶
Badge functions create bold, colored status indicators:
pass := printer.SuccessBadge("PASS")
fail := printer.ErrorBadge("FAIL")
warn := printer.WarningBadge("WARN")
Validation Formatting ¶
Specialized functions for doctor command validation output:
line := printer.FormatValidationPass("*", "PASS", "Config", "Valid YAML")
line := printer.FormatValidationFail("x", "FAIL", "Version", "Invalid format")
line := printer.FormatValidationWarn("!", "WARN", "Plugin", "Deprecated option")
Color Control ¶
Disable colors for non-TTY or user preference:
printer.SetNoColor(true)
This also respects the NO_COLOR environment variable.
Index ¶
- func Bold(text string) string
- func Error(text string) string
- func ErrorBadge(text string) string
- func Faint(text string) string
- func FormatValidationFail(symbol, badge, category, message string) string
- func FormatValidationFaint(symbol, badge, category, message string) string
- func FormatValidationPass(symbol, badge, category, message string) string
- func FormatValidationWarn(symbol, badge, category, message string) string
- func Info(text string) string
- func PrintBold(text string)
- func PrintError(text string)
- func PrintFaint(text string)
- func PrintInfo(text string)
- func PrintSuccess(text string)
- func PrintWarning(text string)
- func SetNoColor(disabled bool)
- func Success(text string) string
- func SuccessBadge(text string) string
- func Warning(text string) string
- func WarningBadge(text string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatValidationFail ¶
FormatValidationFail formats a validation result with FAIL status. Symbol and badge are bold red, category is normal, message is faint.
func FormatValidationFaint ¶
FormatValidationFaint formats a validation result with all faint styling. Used for disabled or inactive items.
func FormatValidationPass ¶
FormatValidationPass formats a validation result with PASS status. Symbol and badge are bold green, category is normal, message is faint.
func FormatValidationWarn ¶
FormatValidationWarn formats a validation result with WARN status. Symbol and badge are bold yellow, category is normal, message is faint.
func PrintSuccess ¶
func PrintSuccess(text string)
PrintSuccess prints text with success (green) styling.
func PrintWarning ¶
func PrintWarning(text string)
PrintWarning prints text with warning (yellow) styling.
func SetNoColor ¶
func SetNoColor(disabled bool)
SetNoColor controls whether the printer uses colors. This respects the --no-color flag and NO_COLOR environment variable.
func SuccessBadge ¶
SuccessBadge returns a bold, green styled badge.
func WarningBadge ¶
WarningBadge returns a bold, yellow styled badge.
Types ¶
This section is empty.