Documentation
¶
Index ¶
- Constants
- func ClearLine()
- func ProgressBar(runner func(current *int), text string, finished string, max int, bar int, ...)
- func ProgressCycle(runner func(done *bool), text string, finished string, cycle string, ...)
- func ProgressDots(runner func(done *bool), text string, finished string, count int, ...)
- type ColourSet
- type Progress
Constants ¶
const ( DEFAULT_PRIMARY = colour.FgHiCyan DEFAULT_SECONDARY = colour.FgHiMagenta DEFAULT_SUCCESS = colour.FgHiGreen DEFAULT_ERROR = colour.FgHiRed DEFAULT_BRACKET = colour.FgHiBlack )
const ( DEFAULT_DELAY = time.Millisecond * 500 DEFAULT_ELEMENTS = "/|\\-" DEFAULT_DOT_COUNT = 3 DEFAULT_BAR_LENGTH = 20 DEFAULT_SHOW_PERCENTAGE = true )
Variables ¶
This section is empty.
Functions ¶
func ProgressBar ¶
func ProgressBar(runner func(current *int), text string, finished string, max int, bar int, showPercentage bool, delay time.Duration, colours *ColourSet)
Receives progress from the goroutine `runner` through `current`. Current is parsed as a fraction of `max` and displayed in the terminal as a progress bar. The length of the progress bar is determined by the `bar` value. The progress bar will changed to a finished state when `current` is equal to `max`. `delay` is the update frequency.
func ProgressCycle ¶
func ProgressCycle(runner func(done *bool), text string, finished string, cycle string, delay time.Duration, colours *ColourSet)
Prints `text` with a cyclic prefix (e.g. \ -> | -> / -> -). The cycle characters are specified through the `cycle` slice. Changes to the next `cycle` string every `delay` duration. Stops when `done` is `true`.
func ProgressDots ¶
func ProgressDots(runner func(done *bool), text string, finished string, count int, delay time.Duration, colours *ColourSet)
Displays `text` with a series of trailing dots. Adds another dot every `delay` duration. The maximum number of dots is specified by the `count` integer. Changes to finished text when `done` is equal to `true`.
Types ¶
type ColourSet ¶
type ColourSet struct {
Primary *colour.Color
Secondary *colour.Color
Success *colour.Color
Error *colour.Color
Bracket *colour.Color
}
Holds primary, secondary, success, error and bracket colours.
func NewColourSet ¶
func NewColourSet() *ColourSet
Creates and returns a default `ColourSet` object.
type Progress ¶
type Progress struct {
// general
Delay time.Duration
// cycle
Elements string
DotCount int
// bar
BarLength int
ShowPercentage bool
// colourset
Colours *ColourSet
}
Holds presets for the progress functions. This is useful if you re-use progress bars or cycles in your project.
func NewProgress ¶
func NewProgress() *Progress
Initialises and returns a default `Progress` instance.
