progress

package
v0.0.0-...-036eace Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2020 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()

MockMeter mocks the meter instance for testing purposes

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()

Finished finishes the progress display

func (*ANSIMeter) Notify

func (*ANSIMeter) Notify(msgstr string)

Notify notifies the user of miscellaneous events

func (*ANSIMeter) Set

func (p *ANSIMeter) Set(current float64)

Set sets progress to the "current" step

func (*ANSIMeter) SetTotal

func (p *ANSIMeter) SetTotal(total float64)

SetTotal sets "total" steps needed

func (*ANSIMeter) Spin

func (p *ANSIMeter) Spin(msgstr string)

Spin indicates indefinite activity by showing a spinner

func (*ANSIMeter) Start

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

Start progress with max "total" steps

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()

Finished finishes the progress display

func (NullMeter) Notify

func (NullMeter) Notify(string)

Notify notifies the user of miscellaneous events

func (NullMeter) Set

func (NullMeter) Set(float64)

Set sets progress to the "current" step

func (NullMeter) SetTotal

func (NullMeter) SetTotal(float64)

SetTotal sets "total" steps needed

func (NullMeter) Spin

func (NullMeter) Spin(msg string)

Spin indicates indefinite activity by showing a spinner

func (NullMeter) Start

func (NullMeter) Start(string, float64)

Start progress with max "total" steps

func (NullMeter) Write

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

Finished finishes the progress display

type QuietMeter

type QuietMeter struct{ NullMeter }

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

func (QuietMeter) Notify

func (QuietMeter) Notify(msg string)

Notify notifies the user of miscellaneous events

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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