Skip to content

Latest commit

 

History

History
79 lines (61 loc) · 6.13 KB

progressbar.md

File metadata and controls

79 lines (61 loc) · 6.13 KB

ProgressbarPrinter

ProgressbarPrinter Example

(Show source of demo)

Usage

Basic usage

progressbar := pterm.DefaultProgressbar.WithTotal(totalSteps).Start()
// Logic here
progressbar.Increment()
// More logic

Functions

Function Description
Add(count int) Add count to current value.
GetElapsedTime() GetElapsedTime returns the elapsed time, since the ProgressbarPrinter was started.
Increment() Increment current value by one.
UpdateTitle(title string) Update the progressbar's title.

Options

To make a copy with modified options you can use: pterm.DefaultProgressbar.WithOptionName(option)

To change multiple options at once, you can chain the functions: pterm.DefaultProgressbar.WithOptionName(option).WithOptionName2(option2)...

Tip

Click the options and types to show the documentation on pkg.go.dev

Option Type
BarCharacter string
BarStyle *Style
Current int
ElapsedTimeRoundingFactor time.Duration
LastCharacter string
RemoveWhenDone ...bool
ShowCount ...bool
ShowElapsedTime ...bool
ShowPercentage ...bool
ShowTitle ...bool
Title string
TitleStyle *Style
Total int
BarFiller string
MaxWidth int
Writer io.Writer

Output functions

This printer implements the interface LivePrinter

Function Description
Start() Returns itself and possible errors
Stop() Returns itself and possible errors
GenericStart() Returns the started LivePrinter and possible errors
GenericStop() Returns the stopped LivePrinter and possible errors

Note

The generic start and stop methods are only used to implement the printer into the interface. Use the normal Start() and Stop() methods if possible.

Related