style

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package style is flate's terminal presentation layer: the glyphs, lipgloss color helpers, ANSI-aware truncation, and duration formatting shared by the CLI status bar and the `flate test` report, so both surfaces speak one vocabulary instead of hand-rolling escape codes and symbols.

Color is gated per output writer: callers resolve ColorEnabled(w) once (a pipe, NO_COLOR, CLICOLOR=0, or a dumb terminal renders plain) and thread the bool through, keeping the renderers pure and deterministic for tests.

Index

Constants

View Source
const (
	GlyphPass    = "✓"
	GlyphFail    = "✗"
	GlyphSkip    = "‒"
	GlyphBlocked = "⊘"
	GlyphWarn    = "⚠"
)

Status glyphs shared across surfaces: a passing/success mark, a failure mark, and a skipped/secondary dash. Pair with Pass/Fail/Skip for color.

Variables

This section is empty.

Functions

func Bold

func Bold(s string, color bool) string

Bold renders s bold when color is on, else verbatim.

func ColorEnabled

func ColorEnabled(w io.Writer) bool

ColorEnabled reports whether w should receive ANSI styling. colorprofile.Detect honors NO_COLOR / CLICOLOR(_FORCE) and TTY-ness; anything at or below Ascii (a pipe, a redirect, a dumb terminal) renders plain.

func Cyan

func Cyan(s string, color bool) string

Cyan renders s cyan when color is on, else verbatim.

func Dim

func Dim(s string, color bool) string

Dim renders s faint when color is on, else verbatim.

func Elapsed

func Elapsed(d time.Duration) string

Elapsed renders a duration compactly for live and summary timing: tenths of a second under a minute, m+ss above it.

func Fail

func Fail(s string, color bool) string

Fail renders s as a failure (red) when color is on, else verbatim.

func Pass

func Pass(s string, color bool) string

Pass renders s as a success (green) when color is on, else verbatim.

func Skip

func Skip(s string, color bool) string

Skip renders s as skipped/secondary (faint) when color is on, else verbatim.

func Truncate

func Truncate(s string, width int) string

Truncate shortens s to width visible columns, appending an ellipsis on overflow. It is ANSI- and wide-rune-aware (escape sequences and CJK width are counted correctly), so a styled line truncates by what's actually shown.

func Warn added in v0.4.6

func Warn(s string, color bool) string

Warn renders s as an advisory (yellow) when color is on, else verbatim.

Types

This section is empty.

Jump to

Keyboard shortcuts

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