display

package
v1.41.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package display prints a run of a workflow: its report, rendered as text for a terminal, the progress of its jobs, and what a verbose run shows of its steps, with the secrets of the run hidden in all of it.

Index

Constants

View Source
const (
	IconSuccess  = "✓ "
	IconError    = "✗ "
	IconTriangle = "△ "
	IconCircle   = "⏺"
	IconWait     = "🕐︎"
	IconSkip     = "⏭ "
	IconRetry    = "⟳"
	// IconStepStart marks a step that started, in the progress of a run.
	IconStepStart = "▸"
)

Icon constants. Those of the statuses are the icons of the marks of the style package, followed by a space.

Variables

This section is empty.

Functions

func ColorDim

func ColorDim() *color.Color

ColorDim returns a *color.Color for subdued text

func ColorWarning

func ColorWarning() *color.Color

ColorWarning returns a *color.Color for warnings (yellow)

func NewReporter

func NewReporter(mode Mode, p *Printer, render *Renderer) outcome.Reporter

NewReporter builds the reporter for the given mode.

func TestErrorDetail

func TestErrorDetail(message string) string

TestErrorDetail formats the error a test could not be evaluated for, by its message.

func TypeMismatchDetail

func TypeMismatchDetail(testExpr string, result any) string

TypeMismatchDetail formats a test that did not evaluate to a boolean.

func TypeMismatchText

func TypeMismatchText(testExpr string, result any) string

TypeMismatchText is what a test that did not evaluate to a boolean is told by.

func WarnLine

func WarnLine(msg string) string

WarnLine returns msg as a line of warning, as LogWarn writes it, for what warns without a Printer, such as Load.

Types

type BufferedReporter

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

BufferedReporter keeps the original behaviour: a spinner during the run and the complete report at the end.

func (*BufferedReporter) Finish

func (r *BufferedReporter) Finish(rs *outcome.Run)

func (*BufferedReporter) JobDone

func (r *BufferedReporter) JobDone(jobID string, jr *outcome.Job)

func (*BufferedReporter) Start

func (r *BufferedReporter) Start(name, description string)

func (*BufferedReporter) StepDone

func (r *BufferedReporter) StepDone(jobID string, sr outcome.Step)

func (*BufferedReporter) StepStart

func (r *BufferedReporter) StepStart(jobID, stepName string)

type DebugBlock

type DebugBlock struct {
	strings.Builder
}

DebugBlock collects the lines of a block of verbose output, such as the request and the response of a step, so that the block is written at once. Jobs run concurrently, and a block written a line at a time would have the lines of another job land inside it.

func (*DebugBlock) Line

func (b *DebugBlock) Line(format string, args ...any)

Line adds a line to the block, as LogDebug writes it.

type JobLabeler

type JobLabeler interface {
	LabelJobs(name func(id string) string)
}

JobLabeler is a Reporter that labels what it prints by job, and is told the names of the jobs once the vars they are evaluated with are known.

type Mode

type Mode int

Mode selects how a workflow run delivers its report.

const (
	// ModeAuto picks spinner on an interactive terminal and stream otherwise.
	ModeAuto Mode = iota
	// ModeSpinner shows a spinner while running and prints the whole
	// report once every job has finished.
	ModeSpinner
	// ModeStream prints each job block as soon as it is final and logs
	// step progress to stderr while jobs are still running.
	ModeStream
)

func ParseMode

func ParseMode(s string) (Mode, error)

ParseMode converts a user supplied name into a Mode.

func (Mode) String

func (m Mode) String() string

type Printer

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

Printer implements PrintWriter for console print

func NewPrinter

func NewPrinter(verbose bool) *Printer

NewPrinter creates a new console print writer. Its output is colored whatever it is written to when FORCE_COLOR or PROBE_TTY is 1: the CLI sets PROBE_TTY when its standard output is a terminal, for the printer of an embedded job: that one runs in the process of an action, whose standard output is not the terminal, and what it writes is printed by the run.

func NewPrinterTo

func NewPrinterTo(verbose bool, out, err io.Writer) *Printer

NewPrinterTo returns a printer that writes to out and err and shows no spinner, for a run whose output is captured, as a test captures it.

func (*Printer) AddSpinnerSuffix

func (p *Printer) AddSpinnerSuffix(txt string)

func (*Printer) Err

func (p *Printer) Err() io.Writer

Err is where the printer writes errors, warnings and progress.

func (*Printer) Fprint

func (p *Printer) Fprint(w io.Writer, a ...any)

func (*Printer) Fprintf

func (p *Printer) Fprintf(w io.Writer, f string, a ...any)

func (*Printer) Fprintln

func (p *Printer) Fprintln(w io.Writer, a ...any)

func (*Printer) LogDebug

func (p *Printer) LogDebug(format string, args ...any)

LogDebug prints debug messages (only in verbose mode)

func (*Printer) LogDebugBlock

func (p *Printer) LogDebugBlock(b *DebugBlock)

LogDebugBlock writes a block of verbose output in one write, only in verbose mode.

func (*Printer) LogError

func (p *Printer) LogError(format string, args ...any)

LogError prints error messages to the error writer

func (*Printer) LogTestError

func (p *Printer) LogTestError(testExpr string, err error)

LogTestError logs, in verbose mode, the error a test could not be evaluated for.

func (*Printer) LogWarn

func (p *Printer) LogWarn(format string, args ...any)

LogWarn prints a warning to the error writer: something the user should know about that does not make the run fail.

func (*Printer) Masker

func (p *Printer) Masker() *mask.Masker

Masker returns the masker the printer applies. It is nil when none was installed, and on a nil Printer, which some contexts run without.

func (*Printer) Out

func (p *Printer) Out() io.Writer

Out is where the printer writes the report of a run.

func (*Printer) PrintEchoContent

func (p *Printer) PrintEchoContent(content string)

PrintEchoContent prints echo content with proper indentation in verbose mode

func (*Printer) PrintError

func (p *Printer) PrintError(format string, args ...any)

PrintError prints an error message

func (*Printer) PrintGivenRequest

func (p *Printer) PrintGivenRequest(stepIdx int, stepName string, with map[string]any)

PrintGivenRequest prints, for a step whose action failed without returning the request it made, the parameters the step gave the action, its templates evaluated, in place of the request and the response.

func (*Printer) PrintMapData

func (p *Printer) PrintMapData(data map[string]any)

PrintMapData prints map data in verbose mode as YAML-like lines, its keys sorted, and all of it, as it is: nothing is cut or left out.

func (*Printer) PrintRequestResponse

func (p *Printer) PrintRequestResponse(stepIdx int, stepName string, req, res map[string]any, rt string)

PrintRequestResponse prints request and response data with proper formatting

func (*Printer) PrintSeparator

func (p *Printer) PrintSeparator()

PrintSeparator prints a separator line for verbose output

func (*Printer) PrintTestResult

func (p *Printer) PrintTestResult(success bool, testExpr string, env map[string]any)

PrintTestResult prints, in verbose mode, what the test testExpr came to, with env, the names it was evaluated with, when it is not nil.

func (*Printer) PrintVerbose

func (p *Printer) PrintVerbose(format string, args ...any)

PrintVerbose prints verbose output (only if verbose mode is enabled)

func (*Printer) SetErr

func (p *Printer) SetErr(w io.Writer)

SetErr sets where the printer writes errors, warnings and progress.

func (*Printer) SetMasker

func (p *Printer) SetMasker(m *mask.Masker)

SetMasker installs the masker applied to everything the printer writes.

func (*Printer) SetOut

func (p *Printer) SetOut(w io.Writer)

SetOut sets where the printer writes the report of a run.

func (*Printer) SetVerbose

func (p *Printer) SetVerbose(v bool)

SetVerbose sets whether the printer writes the verbose output of a run.

func (*Printer) StartSpinner

func (p *Printer) StartSpinner()

func (*Printer) StopSpinner

func (p *Printer) StopSpinner()

func (*Printer) Verbose

func (p *Printer) Verbose() bool

Verbose reports whether the printer writes the verbose output of a run.

type Renderer

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

Renderer renders the report of a run as text: a block for each job, in the order the workflow writes them, and a footer, and the lines of the progress of a run. What it renders is shown as it is, so the secrets the masker knows are hidden in it. It writes nothing itself: a Reporter tells when what it renders is printed, and where.

Its methods named write* write their part of the report to the builder they are given, and those named *Text return theirs.

func NewRenderer

func NewRenderer(order []string, baseline *report.Report, masker *mask.Masker) *Renderer

NewRenderer returns a renderer of the jobs of order, which shows the times of the repeated steps against baseline, when it is not nil.

func (*Renderer) FailureText

func (r *Renderer) FailureText(f *outcome.Failure, test string) string

FailureText returns why a step, or a test of a repeated job, failed, as it is shown under it: f is its failure and test its test. A test that is false is told by the condition of it that is false and what that compared, then the request and the response; one that could not be evaluated, or did not come to a boolean, by that; a contract that is broken by where, then the request and the response; and an error by its message. It is empty when f is nil.

func (*Renderer) StepsText

func (r *Renderer) StepsText(rs *outcome.Run) string

StepsText returns the steps of the jobs of rs, in order, without their status lines or the footer: what a job run on its own reports.

type StreamReporter

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

StreamReporter prints the report incrementally.

A job block is only printed once the job is final, which keeps blocks from interleaving even though jobs run concurrently. Blocks are held back until every earlier job in workflow order has been printed, so the finished report is identical to the buffered one. Step level progress goes to stderr, which is what keeps a CI log alive while the first job is still running.

func (*StreamReporter) Finish

func (r *StreamReporter) Finish(rs *outcome.Run)

func (*StreamReporter) JobDone

func (r *StreamReporter) JobDone(jobID string, jr *outcome.Job)

func (*StreamReporter) LabelJobs

func (r *StreamReporter) LabelJobs(name func(id string) string)

LabelJobs labels the progress lines of each job by its name, which name gives for its id. The names are known once the vars they are evaluated with are, which is after Start. Until then a line is labelled by its id.

func (*StreamReporter) Start

func (r *StreamReporter) Start(name, description string)

func (*StreamReporter) StepDone

func (r *StreamReporter) StepDone(jobID string, sr outcome.Step)

func (*StreamReporter) StepStart

func (r *StreamReporter) StepStart(jobID, stepName string)

Jump to

Keyboard shortcuts

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