output

package
v3.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package output provides shared helpers for formatted CLI output with consistent timestamping and deduplication of consecutive identical messages.

Index

Constants

View Source
const TimestampLayout = "15:04:05"

TimestampLayout is the timestamp prefix shared by all CLI output. Wall-clock only: a hot-reload session is watched live, so the date is the same on every line and repeating it costs a column without telling the reader anything.

Variables

This section is empty.

Functions

func Accent

func Accent(s string) string

Accent highlights the payload of a message — a file path, a URL, a duration — against the dim line around it. It restores the dim afterwards, so an accented span can sit mid-message without bleaching the rest of the line.

func Errorln

func Errorln(format string, args ...any)

Errorln prints a failure line. It never participates in dedup: two identical errors are two events worth seeing.

func Link(s string) string

Link highlights a location: a URL, or a path inside the project. Both answer "where", so they share one colour.

func Print

func Print(key, line string)

Print writes line to stdout, appending an " (xN)" suffix when key matches the key of the previous Print. The key carries only the message text, so colour codes and the timestamp never affect whether two lines are considered equal.

func PrintRaw

func PrintRaw(line string)

PrintRaw writes line to stdout without dedup and clears the dedup state. A message that repeats across an intervening PrintRaw is no longer consecutive, so it starts a fresh count rather than resuming the old one.

func Println

func Println(format string, args ...any)

Println prints a timestamped line with consecutive-identical-message dedup.

Timestamp and message are both dim: a build phase is scaffolding, and the timestamp repeats near-identically on every line of a cycle. What matters is wrapped in Accent by the caller, so a screen full of these lines has a few bright points to read instead of a uniform wall.

func ResetDedup

func ResetDedup()

ResetDedup clears the consecutive-message state.

func StripANSI

func StripANSI(s string) string

StripANSI returns s without its ANSI escape sequences.

func Tag

func Tag(s string) string

Tag names the subsystem a line comes from, in the brand accent. Plain, not bold: the accent alone is loud enough, and bold on a saturated magenta reads as shouting.

func Timestamp

func Timestamp() string

Timestamp returns the current time in the CLI's standard layout.

Types

type LineFilter

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

LineFilter wraps a writer and drops whole lines for which drop reports true. Writes arrive in arbitrary chunks, so partial lines are buffered until their newline shows up and the decision can be made on the complete line.

func NewLineFilter

func NewLineFilter(w io.Writer, drop func(string) bool) *LineFilter

NewLineFilter returns a writer that forwards to w every line drop rejects.

func (*LineFilter) Write

func (f *LineFilter) Write(p []byte) (int, error)

Write buffers p and forwards the complete lines that survive the filter. It always reports len(p) consumed: a dropped line is still fully handled, and reporting a short write would look like an I/O error to the producer.

Jump to

Keyboard shortcuts

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