reporter

package
v3.42.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package reporter abstracts the progress output of long-running operations, so the same gitlab and git code can drive a terminal spinner in the CLI and a streamed log in the web server.

It lives in its own package because config, git and gitlab all report progress, and a shared type in any one of them would pull the others into an import cycle. reporter imports nothing from the project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsoleReporter

type ConsoleReporter struct{}

ConsoleReporter is the CLI reporter: spinners for tasks, stdout for lines. It reproduces the terminal output glabs had before the reporter existed, so the yacspin configuration here matches what the operation code used inline.

func NewConsoleReporter

func NewConsoleReporter() *ConsoleReporter

func (*ConsoleReporter) Printf

func (r *ConsoleReporter) Printf(format string, a ...any)

func (*ConsoleReporter) Println

func (r *ConsoleReporter) Println(a ...any)

func (*ConsoleReporter) Task

func (r *ConsoleReporter) Task(description string) Task

type DiscardReporter

type DiscardReporter struct{}

DiscardReporter drops everything. It backs the CLI's --suppress mode (where only machine-readable output is wanted) and keeps tests quiet.

func NewDiscardReporter

func NewDiscardReporter() *DiscardReporter

func (*DiscardReporter) Printf

func (r *DiscardReporter) Printf(string, ...any)

func (*DiscardReporter) Println

func (r *DiscardReporter) Println(...any)

func (*DiscardReporter) Task

func (r *DiscardReporter) Task(string) Task

type Reporter

type Reporter interface {
	// Printf writes a formatted line. The format may contain ANSI color codes.
	Printf(format string, a ...any)
	// Println writes its arguments as a line.
	Println(a ...any)
	// Task starts a unit of work shown with a spinner on the console. End it via
	// the returned Task's Done or Fail; exactly one of those must be called.
	Task(description string) Task
}

Reporter receives the progress of an operation. The CLI's ConsoleReporter renders it as spinners and colored lines; the web server will implement one that streams LogLines to the browser.

Callers keep coloring their own text (aurora.Sprintf(...)) and pass the result through Printf/Println, so a console reporter reproduces today's output verbatim and a stream reporter can forward the ANSI codes for the browser to render.

type Task

type Task interface {
	// Update changes the running message while the task is in progress.
	Update(message string)
	// Done ends the task successfully. An empty message keeps the description.
	Done(message string)
	// Fail ends the task as failed, showing message.
	Fail(message string)
}

Task is one unit of work in progress. It maps to a single spinner on the console: a running description that ends in success or failure.

func NopTask

func NopTask() Task

NopTask is a task that does nothing. Operation helpers use it for the "already inside a parent task, don't start my own spinner" case, so their body can call Update/Done/Fail unconditionally instead of branching on a spin flag.

Jump to

Keyboard shortcuts

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