progress

package
v0.0.0-...-8373593 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: GPL-3.0 Imports: 8 Imported by: 204

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(w io.Writer) Meter

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

  • if MockMeter has been called, return that.
  • if w is not nil nor os.Stdout, a QuietMeter outputting to it is returned.
  • if no terminal is attached, or we think we're running a test, a minimalistic QuietMeter outputting to stdout is returned.
  • otherwise, an ANSIMeter is returned.

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
	// contains filtered or unexported fields
}

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

func (QuietMeter) Notify

func (m 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