package progress

import "github.com/docker/compose/v2/pkg/progress"

Index

Constants

const (
	// ModeAuto detect console capabilities
	ModeAuto = "auto"
	// ModeTTY use terminal capability for advanced rendering
	ModeTTY = "tty"
	// ModePlain dump raw events to output
	ModePlain = "plain"
	// ModeQuiet don't display events
	ModeQuiet = "quiet"
	// ModeJSON outputs a machine-readable JSON stream
	ModeJSON = "json"
)

Variables

var (
	DoneColor    colorFunc = aec.BlueF.Apply
	TimerColor   colorFunc = aec.BlueF.Apply
	CountColor   colorFunc = aec.YellowF.Apply
	WarningColor colorFunc = aec.YellowF.With(aec.Bold).Apply
	SuccessColor colorFunc = aec.GreenF.Apply
	ErrorColor   colorFunc = aec.RedF.With(aec.Bold).Apply
	PrefixColor  colorFunc = aec.CyanF.Apply
)
var Mode = ModeAuto

Mode define how progress should be rendered, either as ModePlain or ModeTTY

Functions

func NoColor

func NoColor()

func Run

func Run(ctx context.Context, pf progressFunc, out *streams.Out) error

Run will run a writer and the progress function in parallel

func RunWithStatus

func RunWithStatus(ctx context.Context, pf progressFuncWithStatus, out *streams.Out, progressTitle string) (string, error)

RunWithStatus will run a writer and the progress function in parallel and return a status

func RunWithTitle

func RunWithTitle(ctx context.Context, pf progressFunc, out *streams.Out, progressTitle string) error

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
	ParentID   string
	Text       string
	Status     EventStatus
	StatusText string
	Current    int64
	Percent    int

	Total int64
	// contains filtered or unexported fields
}

Event represents a progress event.

func BuildingEvent

func BuildingEvent(id string) Event

BuildingEvent creates a new Building in progress Event

func BuiltEvent

func BuiltEvent(id string) Event

BuiltEvent creates a new built (done) Event

func CreatedEvent

func CreatedEvent(id string) Event

CreatedEvent creates a new Created (done) Event

func CreatingEvent

func CreatingEvent(id string) Event

CreatingEvent creates a new Create in progress Event

func ErrorEvent

func ErrorEvent(id string) Event

ErrorEvent creates a new Error Event

func ErrorMessageEvent

func ErrorMessageEvent(id string, msg string) Event

ErrorMessageEvent creates a new Error Event with message

func Exited

func Exited(id string) Event

Exited creates a new exited event

func Healthy

func Healthy(id string) Event

Healthy creates a new healthy event

func KilledEvent

func KilledEvent(id string) Event

KilledEvent creates a new Killed in progress Event

func KillingEvent

func KillingEvent(id string) Event

KillingEvent creates a new Killing in progress Event

func NewEvent

func NewEvent(id string, status EventStatus, statusText string) Event

NewEvent new event

func RemovedEvent

func RemovedEvent(id string) Event

RemovedEvent creates a new removed (done) Event

func RemovingEvent

func RemovingEvent(id string) Event

RemovingEvent creates a new Removing in progress Event

func RestartedEvent

func RestartedEvent(id string) Event

RestartedEvent creates a new Restarted in progress Event

func RestartingEvent

func RestartingEvent(id string) Event

RestartingEvent creates a new Restarting in progress Event

func RunningEvent

func RunningEvent(id string) Event

RunningEvent creates a new Running in progress Event

func SkippedEvent

func SkippedEvent(id string, reason string) Event

SkippedEvent creates a new Skipped Event

func StartedEvent

func StartedEvent(id string) Event

StartedEvent creates a new Started in progress Event

func StartingEvent

func StartingEvent(id string) Event

StartingEvent creates a new Starting in progress Event

func StoppedEvent

func StoppedEvent(id string) Event

StoppedEvent creates a new Stopping in progress Event

func StoppingEvent

func StoppingEvent(id string) Event

StoppingEvent creates a new Stopping in progress Event

func Waiting

func Waiting(id string) Event

Waiting creates a new waiting event

func (*Event) Spinner

func (e *Event) Spinner() any

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
	// Warning means that the current task has warning
	Warning
	// Error means that the current task has errored
	Error
)

type Writer

type Writer interface {
	Start(context.Context) error
	Stop()
	Event(Event)
	Events([]Event)
	TailMsgf(string, ...interface{})
}

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(ctx context.Context, out *streams.Out, progressTitle string) (Writer, error)

NewWriter returns a new multi-progress writer

Source Files

colors.go event.go json.go noop.go plain.go quiet.go spinner.go tty.go writer.go

Version
v2.35.1 (latest)
Published
Apr 17, 2025
Platform
linux/amd64
Imports
15 packages
Last checked
20 hours ago

Tools for package owners.