progress

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package progress ships a TTY progress reporter and two actions that publish progress events through kernel/xctx.

The reporter is installed once per pipeline via WrapPipeline. Any action can publish xctx.ReportProgress; the reporter renders it. When stderr is a TTY, long-running steps show an animated spinner with elapsed time. When stderr is redirected, one line per completed step is written so CI logs stay readable.

Typical use:

@require progress

{ duration_ms: 2000 }
-> progress.wrap @{ action: runtime.sleep, message: "Slow op" }
-> progress.step @{ message: "Ready" }

Index

Constants

View Source
const ID = "progress"

Variables

This section is empty.

Functions

func Bundle

func Bundle(_ map[string]string) core.Bundle

func Library

func Library() action.Library

func StepAction

func StepAction() action.AnyAction

StepAction renders one progress line and passes its input through unchanged, minus the message key.

{ x: 1 } -> progress.step @{ message: "Loading" } -> { y: 2 }

After step runs, the pipeline sees { x: 1 }.

func WrapAction

func WrapAction() action.AnyAction

WrapAction resolves its target through the execution resolver and runs the target inside a progress lifecycle. The target receives every field of the wrap input except the wrap-specific keys "action" and "message".

{ duration_ms: 2000 }
-> progress.wrap @{ action: runtime.sleep, message: "Slow op" }

Types

type Reporter

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

Reporter renders xctx.Progress events to a writer. It is safe for concurrent use and safe to Shutdown more than once.

func NewReporter

func NewReporter(out io.Writer) *Reporter

NewReporter returns a Reporter writing to out. A nil writer falls back to os.Stderr. The Reporter detects TTY-ness once at construction.

func (*Reporter) Report

func (r *Reporter) Report(p xctx.Progress)

Report implements xctx.ProgressReporter.

Events are dispatched on Metadata["kind"]:

"step"   — one-shot progress line; current/total are ignored
"wrap"   — lifecycle event; Current==0 starts, Current>=Total ends

A bare Progress with a Message and no kind is rendered as a step, so callers who publish xctx.Progress directly get visible output without having to know this package's metadata convention.

func (*Reporter) Shutdown

func (r *Reporter) Shutdown()

Shutdown stops any active spinner. Safe to call more than once.

Jump to

Keyboard shortcuts

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