decor

package
v3.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KiB = 1 << (iota * 10)
	MiB
	GiB
	TiB
)
View Source
const (
	KB = 1000
	MB = KB * 1000
	GB = MB * 1000
	TB = GB * 1000
)
View Source
const (

	// Unit_KiB Kibibyte = 1024 b
	Unit_KiB
	// Unit_kB Kilobyte = 1000 b
	Unit_kB
)
View Source
const (
	// DidentRight specifies identation direction.
	// |foo   |b     | With DidentRight
	// |   foo|     b| Without DidentRight
	DidentRight = 1 << iota

	// DwidthSync will auto sync max width.
	// Makes sense when there're more than one bar
	DwidthSync

	// DextraSpace adds extra space, makes sense with DwidthSync only.
	// When DidentRight bit set, the space will be added to the right,
	// otherwise to the left.
	DextraSpace

	// DSyncSpace is shortcut for DwidthSync|DextraSpace
	DSyncSpace = DwidthSync | DextraSpace
)

Variables

This section is empty.

Functions

func CalcPercentage

func CalcPercentage(total, current, width int64) (perc int64)

Types

type CounterKB

type CounterKB int64

func (CounterKB) Format

func (c CounterKB) Format(f fmt.State, r rune)

type CounterKiB

type CounterKiB int64

func (CounterKiB) Format

func (c CounterKiB) Format(f fmt.State, r rune)

type DecoratorFunc

type DecoratorFunc func(s *Statistics, myWidth chan<- int, maxWidth <-chan int) string

DecoratorFunc is a function that can be prepended and appended to the progress bar

func Counters

func Counters(pairFormat string, unit Unit, minWidth int, conf byte) DecoratorFunc

Counters provides basic counters decorator. pairFormat must contain two printf compatible verbs, like "%f" or "%d". First verb substituted with Current, second one with Total. For example (assuming decor.Unit_KiB used): "%.1f / %.1f" = "1.0MiB / 12.0MiB" or "% .1f / % .1f" = "1.0 MiB / 12.0 MiB" unit is one of decor.Unit_KiB/decor.Unit_kB or just zero if you need raw unitless numbers.

func CountersKibiByte

func CountersKibiByte(pairFormat string, minWidth int, conf byte) DecoratorFunc

CountersKibiByte returns human friendly byte counters decorator, where counters unit is multiple by 1024.

func CountersKiloByte

func CountersKiloByte(pairFormat string, minWidth int, conf byte) DecoratorFunc

CountersKiloByte returns human friendly byte counters decorator, where counters unit is multiple by 1000.

func CountersNoUnit

func CountersNoUnit(pairFormat string, minWidth int, conf byte) DecoratorFunc

CountersNoUnit returns raw counters decorator

func DynamicName

func DynamicName(nameFn func(*Statistics) string, minWidth int, conf byte) DecoratorFunc

DynamicName to be used, when there is a plan to change the name once or several times during progress rendering process. If there're more than one bar, and you'd like to synchronize column width, conf param should have DwidthSync bit set.

func ETA

func ETA(minWidth int, conf byte) DecoratorFunc

ETA provides exponential-weighted-moving-average ETA decorator. If there're more than one bar, and you'd like to synchronize column width, conf param should have DwidthSync bit set.

func Elapsed

func Elapsed(minWidth int, conf byte) DecoratorFunc

Elapsed provides elapsed time decorator. If there're more than one bar, and you'd like to synchronize column width, conf param should have DwidthSync bit set.

func Name

func Name(name string, minWidth int, conf byte) DecoratorFunc

Name deprecated, use StaticName instead

func Percentage

func Percentage(minWidth int, conf byte) DecoratorFunc

Percentage provides percentage decorator. If there're more than one bar, and you'd like to synchronize column width, conf param should have DwidthSync bit set.

func StaticName

func StaticName(name string, minWidth int, conf byte) DecoratorFunc

StaticName to be used, when there is no plan to change the name during whole life of a progress rendering process

type Statistics

type Statistics struct {
	ID                  int
	Completed           bool
	Aborted             bool
	Total               int64
	Current             int64
	StartTime           time.Time
	TimeElapsed         time.Duration
	TimePerItemEstimate time.Duration
}

Statistics represents statistics of the progress bar. Cantains: Total, Current, TimeElapsed, TimePerItemEstimate

func (*Statistics) Eta

func (s *Statistics) Eta() time.Duration

Eta returns exponential-weighted-moving-average ETA estimator

type Unit

type Unit uint

Jump to

Keyboard shortcuts

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