ui

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ui provides consistent CLI output formatting utilities.

Index

Constants

View Source
const (
	Reset  = "\033[0m"
	Bold   = "\033[1m"
	Dim    = "\033[2m"
	Italic = "\033[3m"
	Under  = "\033[4m"

	// Foreground colors
	Black   = "\033[30m"
	Red     = "\033[31m"
	Green   = "\033[32m"
	Yellow  = "\033[33m"
	Blue    = "\033[34m"
	Magenta = "\033[35m"
	Cyan    = "\033[36m"
	White   = "\033[37m"

	// Bright foreground colors
	BrightBlack   = "\033[90m"
	BrightRed     = "\033[91m"
	BrightGreen   = "\033[92m"
	BrightYellow  = "\033[93m"
	BrightBlue    = "\033[94m"
	BrightMagenta = "\033[95m"
	BrightCyan    = "\033[96m"
	BrightWhite   = "\033[97m"
)

ANSI color codes

Variables

This section is empty.

Functions

func BlankLine

func BlankLine()

BlankLine prints an empty line.

func BlueText

func BlueText(text string) string

BlueText colors text blue.

func BoldText

func BoldText(text string) string

BoldText makes text bold.

func Color

func Color(text, color string) string

Color wraps text in the given color code if colors are enabled.

func ColorEnabled

func ColorEnabled() bool

ColorEnabled returns whether colors are enabled.

func Colorize

func Colorize(text string, codes ...string) string

Colorize applies color to text.

func CyanText

func CyanText(text string) string

CyanText colors text cyan.

func DimText

func DimText(text string) string

DimText makes text dim.

func GrayText

func GrayText(text string) string

GrayText colors text gray (bright black).

func GreenText

func GreenText(text string) string

GreenText colors text green.

func Info

func Info(format string, args ...any)

Info prints an info message with blue arrow.

func MagentaText

func MagentaText(text string) string

MagentaText colors text magenta.

func RedText

func RedText(text string) string

RedText colors text red.

func SetColorEnabled

func SetColorEnabled(enabled bool)

SetColorEnabled overrides automatic color detection.

func SetOutput

func SetOutput(w io.Writer)

SetOutput overrides the output writer (for testing). Pass nil to reset to stdout.

func SimpleTable

func SimpleTable(pairs ...string)

SimpleTable prints a simple key-value table.

func Warning

func Warning(format string, args ...any)

Warning prints a warning message with yellow exclamation.

func YellowText

func YellowText(text string) string

YellowText colors text yellow.

Types

type Table

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

Table represents a formatted table for CLI output.

func NewTable

func NewTable(headers ...string) *Table

NewTable creates a new table with the given headers.

func (*Table) AddRow

func (t *Table) AddRow(values ...string)

AddRow adds a row to the table.

func (*Table) Print

func (t *Table) Print()

Print renders and prints the table.

func (*Table) String

func (t *Table) String() string

String renders the table as a string.

Jump to

Keyboard shortcuts

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