progress

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, pf progressFunc) (string, error)

Run will run a writer and the progress function in parallel

func WithContextWriter

func WithContextWriter(ctx context.Context, writer Writer) context.Context

WithContextWriter adds the writer to the context

Types

type Event

type Event struct {
	ID         string
	Text       string
	Status     EventStatus
	StatusText string
	Done       bool
	// contains filtered or unexported fields
}

Event represents a progress event.

type EventStatus

type EventStatus int

EventStatus indicates the status of an action

const (
	// Working means that the current task is working
	Working EventStatus = iota
	// Done means that the current task is done
	Done
	// Error means that the current task has errored
	Error
)

type Writer

type Writer interface {
	Start(context.Context) error
	Stop()
	Event(Event)
}

Writer can write multiple progress events

func ContextWriter

func ContextWriter(ctx context.Context) Writer

ContextWriter returns the writer from the context

func NewWriter

func NewWriter(out console.File) (Writer, error)

NewWriter returns a new multi-progress writer

Jump to

Keyboard shortcuts

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