pretty

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 4 Imported by: 1

README

Pretty

Package pretty provides utilities for beautifying console output.

Progress

$ go run cmd/progress/main.go

2025/03/12 09:53:42 pretty: [=========================>                   ]  59%

Table

$ go run cmd/table/main.go

2025/09/01 14:03:52 pretty: City name Area Population Annual Rainfall
2025/09/01 14:03:52 pretty: -----------------------------------------
2025/09/01 14:03:52 pretty: Adelaide  1295 1158259    600.5
2025/09/01 14:03:52 pretty: Brisbane  5905 1857594    1146.4
2025/09/01 14:03:52 pretty: Darwin    112  120900     1714.7
2025/09/01 14:03:52 pretty: Hobart    1357 205556     619.5
2025/09/01 14:03:52 pretty: Melbourne 1566 3806092    646.9
2025/09/01 14:03:52 pretty: Perth     5386 1554769    869.4
2025/09/01 14:03:52 pretty: Sydney    2058 4336374    1214.8

Tree

$ go run cmd/tree/main.go

2025/09/08 16:39:26 pretty: .
2025/09/08 16:39:26 pretty: ├── README.md
2025/09/08 16:39:26 pretty: ├── cmd
2025/09/08 16:39:26 pretty: │   ├── progress
2025/09/08 16:39:26 pretty: │   │   └── main.go
2025/09/08 16:39:26 pretty: │   ├── table
2025/09/08 16:39:26 pretty: │   │   └── main.go
2025/09/08 16:39:26 pretty: │   └── tree
2025/09/08 16:39:26 pretty: │       └── main.go
2025/09/08 16:39:26 pretty: └── pretty.go

Documentation

Overview

Package pretty provides utilities for beautifying console output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Progress added in v1.0.3

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

Progress represents a progress bar in the terminal.

func NewProgress added in v1.0.3

func NewProgress() *Progress

NewProgress creates a new Progress instance.

func (*Progress) Update added in v1.0.3

func (p *Progress) Update(percent float64)

Update updates the progress bar to the specified percent (0 to 1).

type ProgressWriter added in v1.0.3

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

ProgressWriter is an io.Writer that updates a progress bar as data is written.

func NewProgressWriter added in v1.0.3

func NewProgressWriter(size int64) *ProgressWriter

NewProgressWriter creates a new ProgressWriter for a task of the given size.

func (*ProgressWriter) Write added in v1.0.3

func (p *ProgressWriter) Write(b []byte) (int, error)

Write writes data to the ProgressWriter and updates the progress bar.

type Table added in v1.0.3

type Table struct {
	Head []string
	Body [][]string
}

Table represents a table structure with a head and body.

func NewTable added in v1.0.3

func NewTable() *Table

NewTable creates a new Table instance.

func (*Table) Print added in v1.0.3

func (t *Table) Print()

Print prints the table to the console with proper alignment.

type Tree added in v1.0.3

type Tree struct {
	Name string
	Leaf []*Tree
}

Tree represents a node in a tree structure.

func NewTree added in v1.0.3

func NewTree(name string) *Tree

NewTree creates a new Tree node with the given name.

func (*Tree) Print added in v1.0.3

func (t *Tree) Print()

Print prints the tree structure starting from the root node.

Directories

Path Synopsis
cmd
progress command
table command
tree command

Jump to

Keyboard shortcuts

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