package
4.3.0+incompatible
Repository: https://github.com/static-flow/go-pretty.git
Documentation: pkg.go.dev

# README

Progress

GoDoc

Track the Progress of one or more Tasks (like downloading multiple files in parallel).

  • Track one or more Tasks at the same time
  • Dynamically add one or more Task Trackers while Render() is in progress
  • Choose to have the Writer auto-stop the Render when no more Trackers are in queue, or manually stop using Stop()
  • Redirect output to an io.Writer object (like os.StdOut)
  • Completely customizable styles
    • Many ready-to-use styles: style.go
    • Colorize various parts of the Tracker using StyleColors
    • Customize how Trackers get rendered using StyleOptions

Sample Progress Tracking:

Calculating Total   #  1 ... done! [3.25K in 100ms]
Calculating Total   #  2 ... done! [6.50K in 100ms]
Downloading File    #  3 ... done! [9.75KB in 100ms]
Transferring Amount #  4 ... done! [$26.00K in 200ms]
Transferring Amount #  5 ... done! [£32.50K in 201ms]
Downloading File    #  6 ... done! [58.50KB in 300ms]
Calculating Total   #  7 ... done! [91.00K in 400ms]
Transferring Amount #  8 ... 60.9% (●●●●●●●●●●●●●●◌◌◌◌◌◌◌◌◌) [$78.00K in 399.071ms]
Downloading File    #  9 ... 32.1% (●●●●●●●○◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌) [58.50KB in 298.947ms]
Transferring Amount # 10 ... 13.0% (●●○◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌) [£32.50K in 198.84ms]

Real-time playback of the demo @ asciinema.org: asciicast

A demonstration of all the capabilities can be found here: ../cmd/demo-progress

TODO

  • Optimize CPU and Memory Usage

# Functions

FormatBytes formats the given value as a "Byte".
FormatNumber formats the given value as a "regular number".
NewWriter initializes and returns a Writer.

# Constants

PositionLeft will make the Tracker be displayed first before the Message.
PositionRight will make the Tracker be displayed after the Message.
SortByMessage sorts by the Message alphabetically in ascending order.
SortByMessageDsc sorts by the Message alphabetically in descending order.
SortByNone doesn't do any sorting == sort by insertion order.
SortByPercent sorts by the Percentage complete in ascending order.
SortByPercentDsc sorts by the Percentage complete in descending order.
SortByValue sorts by the Value in ascending order.
SortByValueDsc sorts by the Value in descending order.

# Variables

DefaultLengthTracker defines a sane value for a Tracker's length.
DefaultUpdateFrequency defines a sane value for the frequency with which all the Tracker's get updated on the screen.
StyleBlocks uses UNICODE Block Drawing characters to render the Trackers.
StyleCharsBlocks uses UNICODE Block Drawing characters.
StyleCharsCircle uses UNICODE Circle characters.
StyleCharsDefault uses simple ASCII characters.
StyleCharsRhombus uses UNICODE Rhombus characters.
StyleCircle uses UNICODE Circle runes to render the Trackers.
StyleColorsDefault defines sane color choices - None.
StyleColorsExample defines a few choice color options.
StyleDefault uses ASCII text to render the Trackers.
StyleOptionsDefault defines sane defaults for the Options.
StyleRhombus uses UNICODE Rhombus runes to render the Trackers.
UnitsBytes defines the value as a storage unit.
UnitsCurrencyDollar defines the value as a Dollar amount.
UnitsCurrencyEuro defines the value as a Euro amount.
UnitsCurrencyPound defines the value as a Pound amount.
UnitsDefault doesn't define any units.

# Structs

Progress helps track progress for one or more tasks.
Style declares how to render the Progress/Trackers.
StyleChars defines the characters/strings to use for rendering the Tracker.
StyleColors defines what colors to use for various parts of the Progress and Tracker texts.
StyleOptions defines misc.
Tracker helps track the progress of a single task.
Units defines the "type" of the value being tracked by the Tracker.

# Interfaces

Writer declares the interfaces that can be used to setup and render a Progress tracker with one or more trackers.

# Type aliases

Position defines the position of the Tracker with respect to the Tracker's Message.
SortBy helps sort a list of Trackers by various means.