progressbar

package module
v0.0.0-...-1d8f542 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: MIT Imports: 12 Imported by: 0

README

progressbar

a simple thread-safe progress bar implemented by GO

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(p *ProgressBar)

Option is the type all options need to adhere to

func OptionEnableColorCodes

func OptionEnableColorCodes(colorCodes bool) Option

OptionEnableColorCodes enables or disables support for color codes using mitchellh/colorstring

func OptionFullWidth

func OptionFullWidth() Option

OptionFullWidth sets the bar to be full width

func OptionOnCompletion

func OptionOnCompletion(cmpl func()) Option

OptionOnCompletion will invoke cmpl function once its finished

func OptionSetDescription

func OptionSetDescription(description string) Option

OptionSetDescription sets the description of the bar to render in front of it

func OptionSetRenderBlankState

func OptionSetRenderBlankState(r bool) Option

OptionSetRenderBlankState sets whether to render a 0% bar on construction

func OptionSetTheme

func OptionSetTheme(t Theme) Option

OptionSetTheme sets the elements the bar is constructed of

func OptionSetWidth

func OptionSetWidth(width int) Option

OptionSetWidth sets the width of the bar

func OptionSetWriter

func OptionSetWriter(w io.Writer) Option

OptionSetWriter sets the output writer (defaults to os.Stdout)

func OptionShowBytes

func OptionShowBytes(val bool) Option

OptionShowBytes will update the progress bar configuration settings to display/hide KBytes/Sec

func OptionShowCount

func OptionShowCount() Option

OptionShowCount will also print current count out of total

func OptionSpinnerType

func OptionSpinnerType(spinnerType int) Option

OptionSpinnerType sets the type of spinner used for indeterminate bars

func OptionThrottle

func OptionThrottle(duration time.Duration) Option

OptionThrottle will wait the specified duration before updating again. The default duration is 0 seconds.

type ProgressBar

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

func Default

func Default(max int64, description ...string) *ProgressBar

Default provides a progress bar with recommended defaults. Set max to -1 to use as a spinner.

func NewOptions64

func NewOptions64(max int64, options ...Option) *ProgressBar

func (*ProgressBar) Add

func (p *ProgressBar) Add(num int) error

Add will add the specified amount to the progress bar

func (*ProgressBar) Add64

func (p *ProgressBar) Add64(num int64) error

Add64 will add the specified amount to the progress bar

func (*ProgressBar) RenderBlank

func (p *ProgressBar) RenderBlank() error

RenderBlank renders the current bar state, you can use this to render a 0% state

func (*ProgressBar) String

func (p *ProgressBar) String() string

String returns the current rendered version of the progress bar. It will never return an empty string while the progress bar is running.

type State

type State struct {
	CurrentPercent float64
	CurrentBytes   float64
	SecondsSince   float64
	SecondsLeft    float64
	KBsPerSecond   float64
}

State is the basic properties of the bar

type Theme

type Theme struct {
	Saucer        string
	AltSaucerHead string
	SaucerHead    string
	SaucerPadding string
	BarStart      string
	BarEnd        string
}

Theme defines the elements of the bar

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳