avyos.dev/pkg/format
package format
Overview
No package-level documentation is provided.
| Export Group | Count |
|---|---|
| Constants | 1 |
| Variables | 0 |
| Functions | 9 |
| Types | 3 |
Constants
Reset, Bold, Dim, Underline, Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, BgBlack, BgRed, BgGreen, BgYellow, BgBlue, BgMagenta, BgCyan, BgWhite
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
Functions
Color
func Color(color, text string) stringColor applies a color to text if colors are enabled.
DisableColor
func DisableColor()DisableColor disables color output.
EnableColor
func EnableColor()EnableColor enables color output.
Error
func Error(format string, args ...any)Error formats an error message in red.
Info
func Info(format string, args ...any)Info formats an info message in cyan.
Percent
func Percent(value, total float64) stringPercent formats a percentage.
Size
func Size(bytes int64) stringSize formats a byte count as a human-readable string.
Success
func Success(format string, args ...any)Success formats a success message in green.
Warn
func Warn(format string, args ...any)Warn formats a warning message in yellow.
Types
ProgressBar
type ProgressBar struct {
// contains filtered or unexported fields
}ProgressBar represents a progress bar.
Functions
NewProgressBar
func NewProgressBar(total int64, width int) *ProgressBarNewProgressBar creates a new progress bar.
Methods
Finish
func (p *ProgressBar) Finish()Finish completes the progress bar.
Increment
func (p *ProgressBar) Increment(n int64)Increment increments the progress by n.
SetLabel
func (p *ProgressBar) SetLabel(label string)SetLabel sets the label for the progress bar.
Update
func (p *ProgressBar) Update(current int64)Update updates the progress bar.
Table
type Table struct {
// contains filtered or unexported fields
}Table represents a formatted table.
Functions
NewTable
func NewTable(headers ...string) *TableNewTable creates a new table with the given headers.
Methods
AddRow
func (t *Table) AddRow(cols ...string)AddRow adds a row to the table.
Print
func (t *Table) Print()Print prints the table to stdout.
String
func (t *Table) String() stringString returns the formatted table as a string.
Tree
type Tree struct {
// contains filtered or unexported fields
}Tree represents a tree structure for display.
Functions
NewTree
func NewTree(label string) *TreeNewTree creates a new tree node.
Methods
AddChild
func (t *Tree) AddChild(child *Tree) *TreeAddChild adds a child node to the tree.
AddChildLabel
func (t *Tree) AddChildLabel(label string) *TreeAddChildLabel adds a child with the given label.
Print
func (t *Tree) Print()Print prints the tree to stdout.
String
func (t *Tree) String() stringString returns the tree as a formatted string.