progress

package
v2.3.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package progress provides common progress monitoring / display features NOTE: Subject to change, do not rely on this package from outside git-lfs source

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DryRun

func DryRun(dryRun bool) meterOption

DryRun is an option for NewMeter() that determines whether updates should be sent to stdout.

func WithLogFile

func WithLogFile(name string) meterOption

WithLogFile is an option for NewMeter() that sends updates to a text file.

func WithOSEnv

func WithOSEnv(os env) meterOption

WithOSEnv is an option for NewMeter() that sends updates to the text file path specified in the OS Env.

Types

type BodyWithCallback

type BodyWithCallback struct {
	ReadSeekCloser
	// contains filtered or unexported fields
}

func NewBodyWithCallback

func NewBodyWithCallback(body ReadSeekCloser, totalSize int64, cb CopyCallback) *BodyWithCallback

func NewByteBodyWithCallback

func NewByteBodyWithCallback(by []byte, totalSize int64, cb CopyCallback) *BodyWithCallback

func (*BodyWithCallback) Read

func (r *BodyWithCallback) Read(p []byte) (int, error)

Read wraps the underlying Reader's "Read" method. It also captures the number of bytes read, and calls the callback.

func (*BodyWithCallback) ResetProgress

func (r *BodyWithCallback) ResetProgress() error

ResetProgress calls the callback with a negative read size equal to the total number of bytes read so far, effectively "resetting" the progress.

func (*BodyWithCallback) Seek

func (r *BodyWithCallback) Seek(offset int64, whence int) (int64, error)

Seek wraps the underlying Seeker's "Seek" method, updating the number of bytes that have been consumed by this reader.

type CallbackReader

type CallbackReader struct {
	C         CopyCallback
	TotalSize int64
	ReadSize  int64
	io.Reader
}

func (*CallbackReader) Read

func (w *CallbackReader) Read(p []byte) (int, error)

type CopyCallback

type CopyCallback func(totalSize int64, readSoFar int64, readSinceLast int) error

type Meter

type Meter interface {
	Start()
	Pause()
	Add(int64)
	Skip(size int64)
	StartTransfer(name string)
	TransferBytes(direction, name string, read, total int64, current int)
	FinishTransfer(name string)
	Finish()
}

func Noop

func Noop() Meter

type ProgressMeter

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

ProgressMeter provides a progress bar type output for the TransferQueue. It is given an estimated file count and size up front and tracks the number of files and bytes transferred as well as the number of files and bytes that get skipped because the transfer is unnecessary.

func NewMeter

func NewMeter(options ...meterOption) *ProgressMeter

NewMeter creates a new ProgressMeter.

func (*ProgressMeter) Add

func (p *ProgressMeter) Add(size int64)

Add tells the progress meter that a single file of the given size will possibly be transferred. If a file doesn't need to be transferred for some reason, be sure to call Skip(int64) with the same size.

func (*ProgressMeter) Finish

func (p *ProgressMeter) Finish()

Finish shuts down the ProgressMeter

func (*ProgressMeter) FinishTransfer

func (p *ProgressMeter) FinishTransfer(name string)

FinishTransfer increments the finished transfer count

func (*ProgressMeter) Pause

func (p *ProgressMeter) Pause()

Pause stops sending status updates temporarily, until Start() is called again.

func (*ProgressMeter) Skip

func (p *ProgressMeter) Skip(size int64)

Skip tells the progress meter that a file of size `size` is being skipped because the transfer is unnecessary.

func (*ProgressMeter) Start

func (p *ProgressMeter) Start()

Start begins sending status updates to the optional log file, and stdout.

func (*ProgressMeter) StartTransfer

func (p *ProgressMeter) StartTransfer(name string)

StartTransfer tells the progress meter that a transferring file is being added to the TransferQueue.

func (*ProgressMeter) TransferBytes

func (p *ProgressMeter) TransferBytes(direction, name string, read, total int64, current int)

TransferBytes increments the number of bytes transferred

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Seeker
	io.ReadCloser
}

prevent import cycle

func NewByteBody

func NewByteBody(by []byte) ReadSeekCloser

type Spinner

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

Indeterminate progress indicator 'spinner'

func NewSpinner

func NewSpinner() *Spinner

func (*Spinner) Finish

func (s *Spinner) Finish(out io.Writer, finishMsg string)

Finish the spinner with a completion message & newline

func (*Spinner) Print

func (s *Spinner) Print(out io.Writer, msg string)

Print a spinner (stage) to out followed by msg (no linefeed)

func (*Spinner) Spin

func (s *Spinner) Spin(out io.Writer)

Just spin the spinner one more notch & use the last message

Jump to

Keyboard shortcuts

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