Help us shape the future of Go! Take the 2026 Go Developer Survey

progressbar

package
v2.20.3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ProgressBarWidth = 20

	ProgressRefreshRate = 200 * time.Millisecond
)

Variables

View Source
var ShouldInitProgressBar = func() (bool, error) {
	ci, err := utils.GetBoolEnvValue(coreutils.CI, false)
	if ci || err != nil {
		return false, err
	}
	if !log.IsStdErrTerminal() {
		return false, err
	}
	err = setTerminalWidthVar()
	if err != nil {
		return false, err
	}
	return true, nil
}

The ShouldInitProgressBar func is used to determine whether the progress bar should be displayed. This default implementation will init the progress bar if the following conditions are met: CI == false (or unset) and Stderr is a terminal.

Functions

This section is empty.

Types

type Color

type Color int64
const (
	WHITE Color = iota
	GREEN       = 1
)

type ProgressBarMng

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

func NewBarsMng

func NewBarsMng() (mng *ProgressBarMng, shouldInit bool, err error)

func (*ProgressBarMng) DoneTask

func (bm *ProgressBarMng) DoneTask(prog *TasksWithHeadlineProg)

DoneTask increase tasks counter to the number of totalTasks.

func (*ProgressBarMng) GetBarsWg added in v2.20.0

func (bm *ProgressBarMng) GetBarsWg() *sync.WaitGroup

func (*ProgressBarMng) GetLogFile added in v2.20.0

func (bm *ProgressBarMng) GetLogFile() *os.File

func (*ProgressBarMng) IncBy

func (bm *ProgressBarMng) IncBy(n int, prog *TasksWithHeadlineProg)

Increment increments completed tasks count by n.

func (*ProgressBarMng) Increment

func (bm *ProgressBarMng) Increment(prog *TasksWithHeadlineProg)

Increment increments completed tasks count by 1.

func (*ProgressBarMng) NewCounterProgressBar added in v2.19.0

func (bm *ProgressBarMng) NewCounterProgressBar(num int64, headline string) *TasksProgressBar

func (*ProgressBarMng) NewDoneTasksProgressBar

func (bm *ProgressBarMng) NewDoneTasksProgressBar() *TasksProgressBar

func (*ProgressBarMng) NewHeadlineBar

func (bm *ProgressBarMng) NewHeadlineBar(msg string) *mpb.Bar

func (*ProgressBarMng) NewHeadlineBarWithSpinner

func (bm *ProgressBarMng) NewHeadlineBarWithSpinner(msg string) *mpb.Bar

NewHeadlineBar Initializes a new progress bar for headline, with an optional spinner

func (*ProgressBarMng) NewTasksProgressBar

func (bm *ProgressBarMng) NewTasksProgressBar(totalTasks int64, color Color, taskType string) *TasksProgressBar

func (*ProgressBarMng) NewTasksWithHeadlineProg

func (bm *ProgressBarMng) NewTasksWithHeadlineProg(totalTasks int64, headline string, spinner bool, color Color, taskType string) *TasksWithHeadlineProg

func (*ProgressBarMng) QuitTasksWithHeadlineProg added in v2.20.0

func (bm *ProgressBarMng) QuitTasksWithHeadlineProg(prog *TasksWithHeadlineProg)

type TasksProgressBar added in v2.20.0

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

TasksProgressBar counts tasks that have been completed, using a "%d/%d" format.

func (*TasksProgressBar) GetBar added in v2.20.0

func (p *TasksProgressBar) GetBar() *mpb.Bar

func (*TasksProgressBar) GetTasksCount added in v2.20.0

func (tpb *TasksProgressBar) GetTasksCount() int64

func (*TasksProgressBar) GetTotal added in v2.20.0

func (p *TasksProgressBar) GetTotal() int64

func (*TasksProgressBar) IncGeneralProgressTotalBy added in v2.20.0

func (p *TasksProgressBar) IncGeneralProgressTotalBy(n int64)

IncGeneralProgressTotalBy increments the amount of total by n.

func (*TasksProgressBar) SetGeneralProgressTotal added in v2.20.0

func (p *TasksProgressBar) SetGeneralProgressTotal(n int64)

SetGeneralProgressTotal sets the amount of total to n.

type TasksWithHeadlineProg added in v2.20.0

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

Progress that includes two bars: 1. Headline bar 2. Tasks counter progress bar.

func (*TasksWithHeadlineProg) GetTasksProgressBar added in v2.20.0

func (hp *TasksWithHeadlineProg) GetTasksProgressBar() *TasksProgressBar

Jump to

Keyboard shortcuts

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