pretty

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package pretty provides styled terminal output utilities for CLI applications. Boxes, panels, banners, tables, trees, progress bars, and spinners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBanner

func CreateBanner(title, version, url string, ascii []string) string

CreateBanner renders a double-border banner box with ASCII art, title, version, and URL.

Types

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
}

KeyValuePair is a labelled string value.

type MultiProgress

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

MultiProgress manages multiple progress bars or spinners simultaneously.

func NewMultiProgress

func NewMultiProgress(w io.Writer) *MultiProgress

func (*MultiProgress) Add

func (mp *MultiProgress) Add(item ProgressItem)

func (*MultiProgress) Remove

func (mp *MultiProgress) Remove(item ProgressItem)

func (*MultiProgress) Stop

func (mp *MultiProgress) Stop()

type Pretty

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

Pretty provides formatted output utilities for styled terminal printing.

func New

func New(w io.Writer, theme *velocity.Theme) *Pretty

func (*Pretty) Banner

func (p *Pretty) Banner(text string)

Banner draws a double-border box around text.

func (*Pretty) Box

func (p *Pretty) Box(title, content string)

Box draws a bordered box around content, with an optional title in the top border.

func (*Pretty) Bullet

func (p *Pretty) Bullet(level int, text string)

Bullet prints an indented bullet point at the given nesting level.

func (*Pretty) Debug

func (p *Pretty) Debug(message string)

Debug prints a debug-styled message with nil-safe fallback to stdout.

func (*Pretty) Error

func (p *Pretty) Error(message string)

Error prints an error-styled message with nil-safe fallback to stdout.

func (*Pretty) Info

func (p *Pretty) Info(message string)

Info prints an info-styled message with nil-safe fallback to stdout.

func (*Pretty) KeyValue

func (p *Pretty) KeyValue(key, value string)

KeyValue prints a two-column key: value line with nil-safe fallback.

func (*Pretty) Panel

func (p *Pretty) Panel(title, content string)

Panel draws a simple bordered block with a title bar.

func (*Pretty) Raw

func (p *Pretty) Raw(text string)

Raw writes text directly to the writer without any formatting.

func (*Pretty) Section

func (p *Pretty) Section(title string)

Section prints a titled section header with an underline.

func (*Pretty) Success

func (p *Pretty) Success(message string)

Success prints a success-styled message with nil-safe fallback to stdout.

func (*Pretty) SystemInfo

func (p *Pretty) SystemInfo(info *SystemInfo)

SystemInfo prints a titled block of key-value pairs with nil-safe fallback.

func (*Pretty) Table

func (p *Pretty) Table(headers []string, rows [][]string)

Table renders an aligned table with auto-sized columns.

func (*Pretty) Tree

func (p *Pretty) Tree(nodes []TreeItem)

Tree prints a hierarchy of TreeItem nodes with nil-safe fallback to stdout.

func (*Pretty) Warn

func (p *Pretty) Warn(message string)

Warn prints a warning-styled message with nil-safe fallback to stdout.

type ProgressBar

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

ProgressBar displays progress for long-running operations. Thread-safe for concurrent updates while logging continues.

func NewProgressBar

func NewProgressBar(w io.Writer, total int64, label string) *ProgressBar

func (*ProgressBar) Complete

func (pb *ProgressBar) Complete()

func (*ProgressBar) Increment

func (pb *ProgressBar) Increment(delta int64)

func (*ProgressBar) SetLabel

func (pb *ProgressBar) SetLabel(label string)

func (*ProgressBar) Update

func (pb *ProgressBar) Update(current int64)

type ProgressItem

type ProgressItem interface {
	Render() string
}

ProgressItem is implemented by types that can render themselves as a progress line.

type Spinner

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

Spinner displays an animated spinner for indeterminate progress. Thread-safe and works concurrently with logging.

func NewSpinner

func NewSpinner(w io.Writer, label string) *Spinner

func (*Spinner) SetLabel

func (s *Spinner) SetLabel(label string)

func (*Spinner) SetStyle

func (s *Spinner) SetStyle(style SpinnerStyle)

func (*Spinner) Stop

func (s *Spinner) Stop()

func (*Spinner) StopWithError

func (s *Spinner) StopWithError(message string)

func (*Spinner) StopWithMessage

func (s *Spinner) StopWithMessage(message string)

func (*Spinner) StopWithSuccess

func (s *Spinner) StopWithSuccess(message string)

type SpinnerStyle

type SpinnerStyle int
const (
	SpinnerStyleBraille SpinnerStyle = iota
	SpinnerStyleDots
	SpinnerStyleArrows
	SpinnerStyleBounce
	SpinnerStyleBar
)

type SystemInfo

type SystemInfo struct {
	Title   string
	Version string
	Fields  []KeyValuePair
}

SystemInfo is startup/configuration metadata for display.

type TreeItem

type TreeItem struct {
	Key      string
	Value    any
	Children []TreeItem
}

TreeItem represents a node in a hierarchical display tree.

Jump to

Keyboard shortcuts

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