Documentation
¶
Overview ¶
Package output provides shared helpers for formatted CLI output with consistent timestamping and deduplication of consecutive identical messages.
Index ¶
- Constants
- func Accent(s string) string
- func Errorln(format string, args ...any)
- func Link(s string) string
- func Print(key, line string)
- func PrintRaw(line string)
- func Println(format string, args ...any)
- func ResetDedup()
- func StripANSI(s string) string
- func Tag(s string) string
- func Timestamp() string
- type LineFilter
Constants ¶
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 ¶
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 ¶
Errorln prints a failure line. It never participates in dedup: two identical errors are two events worth seeing.
func Link ¶
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 ¶
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.
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.