progress

package
v0.20.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(bytes int64) string

FormatSize converts bytes to a human-readable string.

Types

type Bar

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

Bar wraps an io.Reader and displays a progress bar to stderr. When reading is complete, the Stop method must be called.

func NewBar

func NewBar(r io.Reader, p *core.Printer, totalBytes int64, onRender func(percentage int64)) *Bar

NewBar returns a new Bar that wraps r and displays a progress bar to stderr via p. The onRender callback, if non-nil, is called on each render with the current completion percentage.

func (*Bar) Read

func (b *Bar) Read(p []byte) (int, error)

func (*Bar) Stop

func (b *Bar) Stop() (bytesRead int64, elapsed time.Duration)

Stop signals the render loop to exit and waits for it to finish. It returns the total bytes read and the elapsed duration.

type Spinner

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

Spinner wraps an io.Reader and displays a bouncing spinner to stderr. When reading is complete, the Stop method must be called.

func NewSpinner

func NewSpinner(r io.Reader, p *core.Printer, onStart func()) *Spinner

NewSpinner returns a new Spinner that wraps r and displays a bouncing spinner to stderr via p. The onStart callback, if non-nil, is called once at the beginning of the render loop.

func (*Spinner) Read

func (s *Spinner) Read(p []byte) (int, error)

func (*Spinner) Stop

func (s *Spinner) Stop() (bytesRead int64, elapsed time.Duration)

Stop signals the render loop to exit and waits for it to finish. It returns the total bytes read and the elapsed duration.

Jump to

Keyboard shortcuts

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