printer

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bold

func Bold(text string) string

Bold returns text with bold styling.

func Error

func Error(text string) string

Error returns text with error (red) styling.

func ErrorBadge

func ErrorBadge(text string) string

ErrorBadge returns a bold, red styled badge.

func Faint

func Faint(text string) string

Faint returns text with faint styling.

func FormatValidationFail

func FormatValidationFail(symbol, badge, category, message string) string

FormatValidationFail formats a validation result with FAIL status. Symbol and badge are bold red, category is normal, message is faint.

func FormatValidationFaint

func FormatValidationFaint(symbol, badge, category, message string) string

FormatValidationFaint formats a validation result with all faint styling. Used for disabled or inactive items.

func FormatValidationPass

func FormatValidationPass(symbol, badge, category, message string) string

FormatValidationPass formats a validation result with PASS status. Symbol and badge are bold green, category is normal, message is faint.

func FormatValidationWarn

func FormatValidationWarn(symbol, badge, category, message string) string

FormatValidationWarn formats a validation result with WARN status. Symbol and badge are bold yellow, category is normal, message is faint.

func Info

func Info(text string) string

Info returns text with info (cyan) styling.

func PrintBold

func PrintBold(text string)

PrintBold prints text with bold styling.

func PrintError

func PrintError(text string)

PrintError prints text with error (red) styling.

func PrintFaint

func PrintFaint(text string)

PrintFaint prints text with faint styling.

func PrintInfo

func PrintInfo(text string)

PrintInfo prints text with info (cyan) styling.

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 Success

func Success(text string) string

Success returns text with success (green) styling.

func SuccessBadge

func SuccessBadge(text string) string

SuccessBadge returns a bold, green styled badge.

func Warning

func Warning(text string) string

Warning returns text with warning (yellow) styling.

func WarningBadge

func WarningBadge(text string) string

WarningBadge returns a bold, yellow styled badge.

Types

This section is empty.

Jump to

Keyboard shortcuts

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