renderers

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT, MIT Imports: 14 Imported by: 1 module, 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 renderers provides LogRendered implementations: SimpleRenderer for linear CI-safe output, InteractiveRenderer for the live tree, StubRenderer for silence, and CI fold decorators.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoRenderer

func AutoRenderer(out *os.File, noColor bool) (termrender.LogRendered, func())

AutoRenderer picks the right renderer for out, mirroring cirrus-cli's auto output: a live tree on capable terminals, plain lines on CI, pipes, and dumb terminals. It returns the renderer and a stop func (deferred after the command runs; a no-op for simple output).

noColor disables ANSI even where supported (--no-color / NO_COLOR). Pass os.Stdout for normal command output.

func NewGithubActionsLogsRenderer

func NewGithubActionsLogsRenderer(renderer *SimpleRenderer) termrender.LogRendered

NewGithubActionsLogsRenderer wraps simple output in GitHub Actions groups.

func NewTeamCityLogsRenderer

func NewTeamCityLogsRenderer(renderer *SimpleRenderer) termrender.LogRendered

NewTeamCityLogsRenderer wraps simple output in TeamCity blocks, escaping service-message metacharacters in scope names.

func NewTravisCILogsRenderer

func NewTravisCILogsRenderer(renderer *SimpleRenderer) termrender.LogRendered

NewTravisCILogsRenderer wraps simple output in Travis fold markers.

Types

type FoldableLogsRenderer

type FoldableLogsRenderer struct {
	StubRenderer
	// contains filtered or unexported fields
}

FoldableLogsRenderer decorates a SimpleRenderer with CI fold markers: a start marker when a scope first opens, an end marker when it closes.

func (FoldableLogsRenderer) RenderMessage

func (r FoldableLogsRenderer) RenderMessage(entry *termrender.LogEntryMessage)

RenderMessage delegates the message unchanged.

func (FoldableLogsRenderer) RenderRawMessage

func (r FoldableLogsRenderer) RenderRawMessage(message string)

RenderRawMessage writes bytes without any decoration.

func (FoldableLogsRenderer) RenderScopeFinished

func (r FoldableLogsRenderer) RenderScopeFinished(entry *termrender.LogScopeFinished)

RenderScopeFinished delegates, then closes the fold with the scope name (upstream left a literal %s here; the name is required to match folds).

func (FoldableLogsRenderer) RenderScopeStarted

func (r FoldableLogsRenderer) RenderScopeStarted(entry *termrender.LogScopeStarted)

RenderScopeStarted opens a fold on first sight, then delegates.

type GithubActionsLogsRenderer

type GithubActionsLogsRenderer struct {
	*FoldableLogsRenderer
}

GithubActionsLogsRenderer wraps simple output in GitHub Actions groups.

type InteractiveRenderer

type InteractiveRenderer struct {
	StubRenderer
	// contains filtered or unexported fields
}

InteractiveRenderer draws a live hierarchical tree with incremental redraws. Run StartDrawing in a goroutine and defer StopDrawing:

renderer := renderers.NewInteractiveRenderer(os.Stdout, nil)
go renderer.StartDrawing()
defer renderer.StopDrawing()

Foreign output (prompts, spinners) must pause the loop first with PauseDrawing and resume after with ResumeDrawing, or both writers garble the terminal.

func NewInteractiveRenderer

func NewInteractiveRenderer(out *os.File, rendererConfig *config.InteractiveRendererConfig) *InteractiveRenderer

NewInteractiveRenderer builds an InteractiveRenderer for a terminal file. A nil config selects emoji on Unix and symbols-only on Windows.

func (*InteractiveRenderer) DrawFrame

func (r *InteractiveRenderer) DrawFrame()

DrawFrame renders one frame with an incremental terminal update, unless paused.

func (*InteractiveRenderer) PauseDrawing

func (r *InteractiveRenderer) PauseDrawing()

PauseDrawing freezes redraws for foreign output (prompts, spinners, bars) sharing the terminal. Tree state is untouched; ResumeDrawing continues where it left off. Safe to call without StartDrawing.

func (*InteractiveRenderer) RenderMessage

func (r *InteractiveRenderer) RenderMessage(entry *termrender.LogEntryMessage)

RenderMessage appends the message to the scope node's description.

func (*InteractiveRenderer) RenderScopeFinished

func (r *InteractiveRenderer) RenderScopeFinished(entry *termrender.LogScopeFinished)

RenderScopeFinished completes the scope node, keeping failure output visible per config and collapsing successes.

func (*InteractiveRenderer) RenderScopeStarted

func (r *InteractiveRenderer) RenderScopeStarted(entry *termrender.LogScopeStarted)

RenderScopeStarted opens (or reuses) the scope node and starts it.

func (*InteractiveRenderer) ResumeDrawing

func (r *InteractiveRenderer) ResumeDrawing()

ResumeDrawing unfreezes redraws after PauseDrawing.

func (*InteractiveRenderer) Setup

func (r *InteractiveRenderer) Setup()

Setup prepares the terminal once: VT processing plus no-autowrap, flushed immediately. Idempotent; StartDrawing calls it too. Call it synchronously before any prompt runs so terminal configuration never races interactive input. All writer access holds the draw lock, so Setup is safe beside a running draw loop.

func (*InteractiveRenderer) StartDrawing

func (r *InteractiveRenderer) StartDrawing()

StartDrawing prepares the terminal and redraws until the root node completes. Run it in a goroutine; setup itself is synchronous so prompts started afterwards see a stable terminal. Only the first call owns the loop; calls after stopping started return silently, so a delayed start can never write past finalized output.

func (*InteractiveRenderer) StopDrawing

func (r *InteractiveRenderer) StopDrawing()

StopDrawing completes the tree, draws the final frame, waits for the background loop to observe completion and exit, then restores autowrap and flushes. Only after it returns is the terminal free for other output: that join is what keeps tables and subsequent writes intact. Safe to call twice and without StartDrawing.

type SimpleRenderer

type SimpleRenderer struct {
	StubRenderer
	// contains filtered or unexported fields
}

SimpleRenderer prints linear lines: "Started 'scope'" then "'scope' succeeded/failed/skipped in <duration>!". Use it for CI, pipes, dumb terminals, and anywhere a live tree cannot draw.

func NewSimpleRenderer

func NewSimpleRenderer(out io.Writer, colors *terminal.ColorSchema) *SimpleRenderer

NewSimpleRenderer builds a SimpleRenderer; nil colors select the default schema.

func (SimpleRenderer) RenderMessage

func (r SimpleRenderer) RenderMessage(entry *termrender.LogEntryMessage)

RenderMessage prints the message as-is.

func (SimpleRenderer) RenderRawMessage

func (r SimpleRenderer) RenderRawMessage(message string)

RenderRawMessage writes bytes without any decoration.

func (SimpleRenderer) RenderScopeFinished

func (r SimpleRenderer) RenderScopeFinished(entry *termrender.LogScopeFinished)

RenderScopeFinished prints "'scope' <outcome> in <duration>!".

func (SimpleRenderer) RenderScopeStarted

func (r SimpleRenderer) RenderScopeStarted(entry *termrender.LogScopeStarted)

RenderScopeStarted prints "Started 'scope'", ignoring duplicates and roots.

func (SimpleRenderer) ScopeHasStarted

func (r SimpleRenderer) ScopeHasStarted(scopes []string) bool

ScopeHasStarted reports whether the scope was seen starting (used by fold decorators to open a fold exactly once).

type StubRenderer

type StubRenderer struct{}

StubRenderer drops every event. Use it for silent runs and tests that exercise logic without asserting output.

func (*StubRenderer) RenderMessage

func (*StubRenderer) RenderMessage(entry *termrender.LogEntryMessage)

RenderMessage drops the event.

func (*StubRenderer) RenderScopeFinished

func (*StubRenderer) RenderScopeFinished(entry *termrender.LogScopeFinished)

RenderScopeFinished drops the event.

func (*StubRenderer) RenderScopeStarted

func (*StubRenderer) RenderScopeStarted(entry *termrender.LogScopeStarted)

RenderScopeStarted drops the event.

Directories

Path Synopsis
Package config tunes the interactive renderer: spinner frames, status glyphs, refresh rate, and failure output visibility.
Package config tunes the interactive renderer: spinner frames, status glyphs, refresh rate, and failure output visibility.
internal
node
Package node implements the goroutine-safe tree node behind the interactive renderer.
Package node implements the goroutine-safe tree node behind the interactive renderer.

Jump to

Keyboard shortcuts

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