format

package
v0.0.0-...-143e6d5 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

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

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

	BgBlack   = "\033[40m"
	BgRed     = "\033[41m"
	BgGreen   = "\033[42m"
	BgYellow  = "\033[43m"
	BgBlue    = "\033[44m"
	BgMagenta = "\033[45m"
	BgCyan    = "\033[46m"
	BgWhite   = "\033[47m"
)

ANSI color codes

Variables

This section is empty.

Functions

func Color

func Color(color, text string) string

Color applies a color to text if colors are enabled.

func DisableColor

func DisableColor()

DisableColor disables color output.

func EnableColor

func EnableColor()

EnableColor enables color output.

func Error

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

Error formats an error message in red.

func Info

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

Info formats an info message in cyan.

func Percent

func Percent(value, total float64) string

Percent formats a percentage.

func Size

func Size(bytes int64) string

Size formats a byte count as a human-readable string.

func Success

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

Success formats a success message in green.

func Warn

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

Warn formats a warning message in yellow.

Types

type ProgressBar

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

ProgressBar represents a progress bar.

func NewProgressBar

func NewProgressBar(total int64, width int) *ProgressBar

NewProgressBar creates a new progress bar.

func (*ProgressBar) Finish

func (p *ProgressBar) Finish()

Finish completes the progress bar.

func (*ProgressBar) Increment

func (p *ProgressBar) Increment(n int64)

Increment increments the progress by n.

func (*ProgressBar) SetLabel

func (p *ProgressBar) SetLabel(label string)

SetLabel sets the label for the progress bar.

func (*ProgressBar) Update

func (p *ProgressBar) Update(current int64)

Update updates the progress bar.

type Table

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

Table represents a formatted table.

func NewTable

func NewTable(headers ...string) *Table

NewTable creates a new table with the given headers.

func (*Table) AddRow

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

AddRow adds a row to the table.

func (*Table) Print

func (t *Table) Print()

Print prints the table to stdout.

func (*Table) String

func (t *Table) String() string

String returns the formatted table as a string.

type Tree

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

Tree represents a tree structure for display.

func NewTree

func NewTree(label string) *Tree

NewTree creates a new tree node.

func (*Tree) AddChild

func (t *Tree) AddChild(child *Tree) *Tree

AddChild adds a child node to the tree.

func (*Tree) AddChildLabel

func (t *Tree) AddChildLabel(label string) *Tree

AddChildLabel adds a child with the given label.

func (*Tree) Print

func (t *Tree) Print()

Print prints the tree to stdout.

func (*Tree) String

func (t *Tree) String() string

String returns the tree as a formatted string.

Jump to

Keyboard shortcuts

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