ui

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blue

func Blue(enabled bool, text string) string

func Bold

func Bold(enabled bool, text string) string

func BoldCyan

func BoldCyan(enabled bool, text string) string

func ColorEnabledForWriter

func ColorEnabledForWriter(w io.Writer) bool

func Cyan

func Cyan(enabled bool, text string) string

func Dim

func Dim(enabled bool, text string) string

func Green

func Green(enabled bool, text string) string

func IsGitHubActions

func IsGitHubActions() bool

IsGitHubActions reports whether the current process is executing inside a GitHub Actions runner. The runner sets GITHUB_ACTIONS=true for every step.

func IsInteractiveWriter

func IsInteractiveWriter(w io.Writer) bool

func Magenta

func Magenta(enabled bool, text string) string

func Red

func Red(enabled bool, text string) string

func RenderProgressBar

func RenderProgressBar(pct, width int) string

RenderProgressBar draws a fixed-width unicode progress bar.

func Style

func Style(enabled bool, text string, codes ...string) string

func Yellow

func Yellow(enabled bool, text string) string

Types

type GHAJobBuffer

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

GHAJobBuffer collects output for a single job. It implements io.Writer so it can be plugged into existing Fprintf-style call sites unchanged.

func (*GHAJobBuffer) Annotation

func (b *GHAJobBuffer) Annotation(level, msg string, props map[string]string)

Annotation writes a workflow-command annotation into the buffer so it is flushed in-order with the surrounding job logs.

func (*GHAJobBuffer) CloseGroup

func (b *GHAJobBuffer) CloseGroup()

CloseGroup writes a matching ::endgroup:: marker.

func (*GHAJobBuffer) OpenGroup

func (b *GHAJobBuffer) OpenGroup(title string)

OpenGroup writes a ::group:: marker into the buffer. GHA does not nest groups; a depth counter is tracked so a Step group inside an already-open Job context degrades gracefully (the inner group becomes a heading line).

func (*GHAJobBuffer) PrintBlock

func (b *GHAJobBuffer) PrintBlock(lines []string)

PrintBlock appends multiple lines to the buffer.

func (*GHAJobBuffer) Println

func (b *GHAJobBuffer) Println(line string)

Println appends a line to the buffer.

func (*GHAJobBuffer) Write

func (b *GHAJobBuffer) Write(p []byte) (int, error)

type GHARenderer

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

GHARenderer emits GitHub Actions-aware output: collapsible log groups, workflow-command annotations, and per-job output buffering so that concurrently executing jobs render as clean, non-interleaved sections in the GitHub Actions log viewer.

Lifecycle:

  • JobBuffer(jobID) returns a per-job sink that callers write into freely.
  • Group(buf, title, fn) wraps fn's writes in ::group::/::endgroup::.
  • FlushJob(jobID) atomically copies the buffered job output to the underlying writer, guaranteeing groups never interleave across jobs.

Color/ANSI is intentionally disabled inside groups: the GHA log viewer renders ANSI but it is noisier than necessary for CI archives.

func NewGHARenderer

func NewGHARenderer(w io.Writer) *GHARenderer

NewGHARenderer constructs a renderer that writes to w. Pass an os.Stdout-like writer; the renderer takes a write lock around every Flush so callers can share the underlying stream safely.

func (*GHARenderer) Error

func (g *GHARenderer) Error(msg string)

func (*GHARenderer) FlushJob

func (g *GHARenderer) FlushJob(jobID string)

FlushJob writes the job buffer's accumulated content to the underlying writer in a single locked operation, then drops the buffer. Safe to call from concurrent goroutines.

func (*GHARenderer) JobBuffer

func (g *GHARenderer) JobBuffer(jobID string) *GHAJobBuffer

JobBuffer returns the per-job output buffer, lazily creating it on first access. Buffers are isolated per jobID so concurrent jobs do not intermix lines until the explicit FlushJob call.

func (*GHARenderer) Notice

func (g *GHARenderer) Notice(msg string)

Notice/Warning/Error emit GHA workflow-command annotations that surface in the PR check summary and the file-based annotation panel.

func (*GHARenderer) Print

func (g *GHARenderer) Print(line string)

Print writes a top-level (non-grouped) line directly to the underlying writer, locked so it cannot tear with concurrent FlushJob calls.

func (*GHARenderer) PrintBlock

func (g *GHARenderer) PrintBlock(lines []string)

PrintBlock writes multiple top-level lines atomically.

func (*GHARenderer) Warning

func (g *GHARenderer) Warning(msg string)

type LiveRegion

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

LiveRegion renders a transient block below the cursor while still allowing persistent lines to be printed above. The block can show a sticky "header" (status counts, progress) plus a windowed list of in-flight rows grouped by component. On non-TTY writers it degrades to plain append-only output: SetRow/RemoveRow become no-ops and Print just writes a line.

func NewLiveRegion

func NewLiveRegion(w io.Writer, tty, color bool) *LiveRegion

NewLiveRegion constructs a live region.

func (*LiveRegion) Print

func (l *LiveRegion) Print(line string)

Print writes a persistent line above the live region.

func (*LiveRegion) PrintBlock

func (l *LiveRegion) PrintBlock(lines []string)

PrintBlock writes multiple persistent lines above the live region.

func (*LiveRegion) RemoveRow

func (l *LiveRegion) RemoveRow(key string)

RemoveRow drops a row from the live region.

func (*LiveRegion) RowCount

func (l *LiveRegion) RowCount() int

RowCount returns the current number of in-flight rows.

func (*LiveRegion) SetHeaderFunc

func (l *LiveRegion) SetHeaderFunc(fn func(activeRows int) []string)

SetHeaderFunc registers a callback that returns sticky header lines drawn above the active rows on every frame. The callback receives the current number of active rows so callers do not need to call RowCount (which would deadlock because draw holds the mutex). Pass nil to clear.

func (*LiveRegion) SetRow

func (l *LiveRegion) SetRow(key, label string)

SetRow inserts or updates a row by key (no group). For component grouping use SetRowDetail instead.

func (*LiveRegion) SetRowDetail

func (l *LiveRegion) SetRowDetail(key, group, label, tail string)

SetRowDetail upserts a row with optional group label and trailing breadcrumb. Empty group/tail leaves the prior values intact when updating.

func (*LiveRegion) SetWindowMax

func (l *LiveRegion) SetWindowMax(n int)

SetWindowMax caps the number of lines used by the active section.

func (*LiveRegion) Start

func (l *LiveRegion) Start()

Start begins the spinner render goroutine. No-op for non-TTY.

func (*LiveRegion) Stop

func (l *LiveRegion) Stop()

Stop ends the render goroutine and clears the live region.

Jump to

Keyboard shortcuts

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