progress

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Null = NullMeter{}

Null is a default NullMeter instance

Functions

func MockMeter

func MockMeter(meter Meter) func()

Types

type ANSIMeter

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

ANSIMeter is a progress.Meter that uses ANSI escape codes to make better use of the available horizontal space.

func (*ANSIMeter) Finished

func (*ANSIMeter) Finished()

func (*ANSIMeter) Notify

func (*ANSIMeter) Notify(msgstr string)

func (*ANSIMeter) Set

func (p *ANSIMeter) Set(current float64)

func (*ANSIMeter) SetTotal

func (p *ANSIMeter) SetTotal(total float64)

func (*ANSIMeter) Spin

func (p *ANSIMeter) Spin(msgstr string)

func (*ANSIMeter) Start

func (p *ANSIMeter) Start(label string, total float64)

func (*ANSIMeter) Write

func (p *ANSIMeter) Write(bs []byte) (n int, err error)

type Meter

type Meter interface {
	// Start progress with max "total" steps
	Start(label string, total float64)

	// set progress to the "current" step
	Set(current float64)

	// set "total" steps needed
	SetTotal(total float64)

	// Finish the progress display
	Finished()

	// Indicate indefinite activity by showing a spinner
	Spin(msg string)

	// interface for writer
	Write(p []byte) (n int, err error)

	// notify the user of miscellaneous events
	Notify(string)
}

Meter is an interface to show progress to the user

func MakeProgressBar

func MakeProgressBar() Meter

MakeProgressBar creates an appropriate progress.Meter for the environ in which it is called:

  • if MockMeter has been called, return that.
  • if no terminal is attached, or we think we're running a test, a minimalistic QuietMeter is returned.
  • otherwise, an ANSIMeter is returned.

TODO: instead of making the pivot at creation time, do it at every call.

type NullMeter

type NullMeter struct{}

NullMeter is a Meter that does nothing

func (NullMeter) Finished

func (NullMeter) Finished()

func (NullMeter) Notify

func (NullMeter) Notify(string)

func (NullMeter) Set

func (NullMeter) Set(float64)

func (NullMeter) SetTotal

func (NullMeter) SetTotal(float64)

func (NullMeter) Spin

func (NullMeter) Spin(msg string)

func (NullMeter) Start

func (NullMeter) Start(string, float64)

func (NullMeter) Write

func (NullMeter) Write(p []byte) (int, error)

type QuietMeter

type QuietMeter struct{ NullMeter }

QuietMeter is a Meter that _just_ shows Notify()s.

func (QuietMeter) Notify

func (QuietMeter) Notify(msg string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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