ui

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ui provides cover100's terminal styling and wire-up to github.com/strongo/logus.

The styling vocabulary — the ✓/i/!/✗ glyphs, the bold headers, the dim/cyan helpers, and the plain "ok:"/"info:"/"warn:"/"error:" fallbacks used when stdout is not a terminal — follows the fleet's other Go CLIs so cover100 looks and pipes like the rest of them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Duration

func Duration(d time.Duration) string

Duration formats a duration the way the fleet's other CLIs do.

func IsTTY

func IsTTY(w io.Writer) bool

IsTTY reports whether w is a character device, matching the fleet's other CLIs, which gate all styling on exactly this check.

func Number

func Number(n int) string

Number formats an integer with comma separators.

func Percent

func Percent(covered, total int) string

Percent formats a covered/total pair as "xx.x%", or "n/a" when the dimension was not measured.

Types

type LogHandler

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

LogHandler adapts github.com/strongo/logus to this Printer. Register it with logus.AddLogEntryHandler so every package that logs through logus lands in cover100's output, filtered by verbosity.

func NewLogHandler

func NewLogHandler(p *Printer) LogHandler

NewLogHandler returns a logus handler backed by p.

func (LogHandler) Log

func (h LogHandler) Log(ctx context.Context, entry logus.LogEntry) error

Log implements logus.LogEntryHandler.

type Printer

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

Printer writes cover100's progress, summary and diagnostics. It is safe for concurrent use: collectors run in parallel and share one Printer.

func New

func New(out, err io.Writer, verbose bool) *Printer

New returns a Printer writing progress to out and warnings, errors and diagnostics to err. Colour is enabled only when out is a terminal and NO_COLOR is unset.

func (*Printer) Blank

func (p *Printer) Blank()

Blank writes an empty line.

func (*Printer) Block

func (p *Printer) Block(text string)

Block writes captured command output, indented and dimmed.

func (*Printer) Bold

func (p *Printer) Bold(format string, args ...any)

Bold writes a section header.

func (*Printer) Debugf

func (p *Printer) Debugf(format string, args ...any)

Debugf writes a diagnostic line only when --verbose is set.

func (*Printer) Detail

func (p *Printer) Detail(format string, args ...any)

Detail writes an indented continuation line under a progress line.

func (*Printer) Error

func (p *Printer) Error(format string, args ...any)

Error writes a failure to stderr.

func (*Printer) Info

func (p *Printer) Info(format string, args ...any)

Info writes a neutral progress line.

func (*Printer) Success

func (p *Printer) Success(format string, args ...any)

Success writes a completed step.

func (*Printer) Table

func (p *Printer) Table(headers []string, rows [][]string)

Table renders an aligned table with a bold header row.

func (*Printer) Verbose

func (p *Printer) Verbose() bool

Verbose reports whether --verbose was passed.

func (*Printer) Warn

func (p *Printer) Warn(format string, args ...any)

Warn writes a warning to stderr.

It deliberately does not mirror through logus: the LogHandler below prints logus entries to the same stream, and routing a user-facing warning through both would report it twice.

Jump to

Keyboard shortcuts

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