Documentation
¶
Overview ¶
Package color provides ANSI 256-color terminal helpers for CLI output.
v1.0 redesign: the API is built around 11-step intensity ramps per hue (step 0 = darkest, step 5 = canonical, step 10 = brightest) plus a red→yellow→green Heat ramp for severity / quality scales. Modifier wrappers (Bold, Reverse) compose with any color helper.
All color helpers emit 256-color SGR sequences (38;5;N). Terminals that don't support 256-color receive uncolored output. NO_COLOR=1 and TERM=dumb also suppress all escapes (https://no-color.org).
Index ¶
- func BgBlu0(v any) string
- func BgBlu1(v any) string
- func BgBlu2(v any) string
- func BgBlu3(v any) string
- func BgBlu4(v any) string
- func BgBlu5(v any) string
- func BgBlu6(v any) string
- func BgBlu7(v any) string
- func BgBlu8(v any) string
- func BgBlu9(v any) string
- func BgBlu10(v any) string
- func BgCya0(v any) string
- func BgCya1(v any) string
- func BgCya2(v any) string
- func BgCya3(v any) string
- func BgCya4(v any) string
- func BgCya5(v any) string
- func BgCya6(v any) string
- func BgCya7(v any) string
- func BgCya8(v any) string
- func BgCya9(v any) string
- func BgCya10(v any) string
- func BgGra0(v any) string
- func BgGra1(v any) string
- func BgGra2(v any) string
- func BgGra3(v any) string
- func BgGra4(v any) string
- func BgGra5(v any) string
- func BgGra6(v any) string
- func BgGra7(v any) string
- func BgGra8(v any) string
- func BgGra9(v any) string
- func BgGra10(v any) string
- func BgGrn0(v any) string
- func BgGrn1(v any) string
- func BgGrn2(v any) string
- func BgGrn3(v any) string
- func BgGrn4(v any) string
- func BgGrn5(v any) string
- func BgGrn6(v any) string
- func BgGrn7(v any) string
- func BgGrn8(v any) string
- func BgGrn9(v any) string
- func BgGrn10(v any) string
- func BgHeat0(v any) string
- func BgHeat1(v any) string
- func BgHeat2(v any) string
- func BgHeat3(v any) string
- func BgHeat4(v any) string
- func BgHeat5(v any) string
- func BgHeat6(v any) string
- func BgHeat7(v any) string
- func BgHeat8(v any) string
- func BgHeat9(v any) string
- func BgHeat10(v any) string
- func BgMag0(v any) string
- func BgMag1(v any) string
- func BgMag2(v any) string
- func BgMag3(v any) string
- func BgMag4(v any) string
- func BgMag5(v any) string
- func BgMag6(v any) string
- func BgMag7(v any) string
- func BgMag8(v any) string
- func BgMag9(v any) string
- func BgMag10(v any) string
- func BgOrg0(v any) string
- func BgOrg1(v any) string
- func BgOrg2(v any) string
- func BgOrg3(v any) string
- func BgOrg4(v any) string
- func BgOrg5(v any) string
- func BgOrg6(v any) string
- func BgOrg7(v any) string
- func BgOrg8(v any) string
- func BgOrg9(v any) string
- func BgOrg10(v any) string
- func BgPur0(v any) string
- func BgPur1(v any) string
- func BgPur2(v any) string
- func BgPur3(v any) string
- func BgPur4(v any) string
- func BgPur5(v any) string
- func BgPur6(v any) string
- func BgPur7(v any) string
- func BgPur8(v any) string
- func BgPur9(v any) string
- func BgPur10(v any) string
- func BgRed0(v any) string
- func BgRed1(v any) string
- func BgRed2(v any) string
- func BgRed3(v any) string
- func BgRed4(v any) string
- func BgRed5(v any) string
- func BgRed6(v any) string
- func BgRed7(v any) string
- func BgRed8(v any) string
- func BgRed9(v any) string
- func BgRed10(v any) string
- func BgWhi0(v any) string
- func BgWhi1(v any) string
- func BgWhi2(v any) string
- func BgWhi3(v any) string
- func BgWhi4(v any) string
- func BgWhi5(v any) string
- func BgWhi6(v any) string
- func BgWhi7(v any) string
- func BgWhi8(v any) string
- func BgWhi9(v any) string
- func BgWhi10(v any) string
- func BgYel0(v any) string
- func BgYel1(v any) string
- func BgYel2(v any) string
- func BgYel3(v any) string
- func BgYel4(v any) string
- func BgYel5(v any) string
- func BgYel6(v any) string
- func BgYel7(v any) string
- func BgYel8(v any) string
- func BgYel9(v any) string
- func BgYel10(v any) string
- func Blu0(v any) string
- func Blu1(v any) string
- func Blu2(v any) string
- func Blu3(v any) string
- func Blu4(v any) string
- func Blu5(v any) string
- func Blu6(v any) string
- func Blu7(v any) string
- func Blu8(v any) string
- func Blu9(v any) string
- func Blu10(v any) string
- func Bold(s string) string
- func ClearCode(s string) string
- func Cya0(v any) string
- func Cya1(v any) string
- func Cya2(v any) string
- func Cya3(v any) string
- func Cya4(v any) string
- func Cya5(v any) string
- func Cya6(v any) string
- func Cya7(v any) string
- func Cya8(v any) string
- func Cya9(v any) string
- func Cya10(v any) string
- func FormatUsage(heading string, lines []UsageLine, footer string) string
- func Gra0(v any) string
- func Gra1(v any) string
- func Gra2(v any) string
- func Gra3(v any) string
- func Gra4(v any) string
- func Gra5(v any) string
- func Gra6(v any) string
- func Gra7(v any) string
- func Gra8(v any) string
- func Gra9(v any) string
- func Gra10(v any) string
- func Grn0(v any) string
- func Grn1(v any) string
- func Grn2(v any) string
- func Grn3(v any) string
- func Grn4(v any) string
- func Grn5(v any) string
- func Grn6(v any) string
- func Grn7(v any) string
- func Grn8(v any) string
- func Grn9(v any) string
- func Grn10(v any) string
- func Heat0(v any) string
- func Heat1(v any) string
- func Heat2(v any) string
- func Heat3(v any) string
- func Heat4(v any) string
- func Heat5(v any) string
- func Heat6(v any) string
- func Heat7(v any) string
- func Heat8(v any) string
- func Heat9(v any) string
- func Heat10(v any) string
- func Mag0(v any) string
- func Mag1(v any) string
- func Mag2(v any) string
- func Mag3(v any) string
- func Mag4(v any) string
- func Mag5(v any) string
- func Mag6(v any) string
- func Mag7(v any) string
- func Mag8(v any) string
- func Mag9(v any) string
- func Mag10(v any) string
- func Org0(v any) string
- func Org1(v any) string
- func Org2(v any) string
- func Org3(v any) string
- func Org4(v any) string
- func Org5(v any) string
- func Org6(v any) string
- func Org7(v any) string
- func Org8(v any) string
- func Org9(v any) string
- func Org10(v any) string
- func Pur0(v any) string
- func Pur1(v any) string
- func Pur2(v any) string
- func Pur3(v any) string
- func Pur4(v any) string
- func Pur5(v any) string
- func Pur6(v any) string
- func Pur7(v any) string
- func Pur8(v any) string
- func Pur9(v any) string
- func Pur10(v any) string
- func Red0(v any) string
- func Red1(v any) string
- func Red2(v any) string
- func Red3(v any) string
- func Red4(v any) string
- func Red5(v any) string
- func Red6(v any) string
- func Red7(v any) string
- func Red8(v any) string
- func Red9(v any) string
- func Red10(v any) string
- func Reverse(s string) string
- func SetEnabled(b bool) func()
- func ShowBgRamps(token string, fgIndex int)
- func ShowGrid(token string, reverse bool, fgIndex int)
- func ShowPalette()
- func Whi0(v any) string
- func Whi1(v any) string
- func Whi2(v any) string
- func Whi3(v any) string
- func Whi4(v any) string
- func Whi5(v any) string
- func Whi6(v any) string
- func Whi7(v any) string
- func Whi8(v any) string
- func Whi9(v any) string
- func Whi10(v any) string
- func Yel0(v any) string
- func Yel1(v any) string
- func Yel2(v any) string
- func Yel3(v any) string
- func Yel4(v any) string
- func Yel5(v any) string
- func Yel6(v any) string
- func Yel7(v any) string
- func Yel8(v any) string
- func Yel9(v any) string
- func Yel10(v any) string
- type UsageLine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bold ¶ added in v1.0.0
Bold wraps s with the ANSI bold attribute. Composable with hue / heat helpers: color.Bold(color.Grn5("text")) renders bold-green. Internal resets inside s are rewritten so the bold attribute survives across multiple colored segments — color.Bold(color.Grn5("a")+color.Red5("b")) renders both segments bold.
func ClearCode ¶ added in v0.2.0
ClearCode strips ANSI/SGR escape sequences from s. Useful for stripping color/formatting from previously-rendered strings or from piped/file input before further processing.
func FormatUsage ¶
FormatUsage builds a formatted help string with a heading, flag table, and optional footer.
func Reverse ¶ added in v1.0.0
Reverse wraps s with the ANSI reverse-video attribute (foreground and background swapped). Composable with hue / heat helpers; same internal- reset rewrite as Bold.
func SetEnabled ¶
func SetEnabled(b bool) func()
SetEnabled is a test helper that mutates package-level color-enablement state. It is NOT safe for concurrent use — tests calling this must NOT call t.Parallel(). The returned closure restores the prior enabled value and is intended for deferred invocation.
func ShowBgRamps ¶ added in v1.4.0
ShowBgRamps prints one row per Bg<Hue> family (10 hues + Heat = 11 rows), each showing the family label followed by 11 step swatches (steps 0..10) as solid background-colored blocks with token rendered inside. Distinct from ShowGrid(token, true, fgIndex), which is a dense bordered ramp×step matrix; ShowBgRamps is a per-family strip optimized for picking a Bg<Hue><Step> at a glance, with always-readable labels.
When fgIndex < 0, the text color is auto-contrasted per step from the bg luminance (white on dark steps, black on light steps) so the token is legible at every step. When fgIndex >= 0 (0..255), that fixed 256-color SGR index is used as the text color across all swatches. If token is empty, "TOKEN" is used.
func ShowGrid ¶ added in v1.1.0
ShowGrid prints a bordered side-by-side grid: every ramp as a column (hue ramps then Heat), every step (0..10) as a row. Column headers use the function-name pattern with "X" as the step placeholder (e.g. RedX, BluX, HeatX); row labels are the X value, with row 5 suffixed "*" to mark the canonical step. Each cell renders token in that ramp/step combo, padded to fill the cell so adjacent close shades separate cleanly along the borders. If token is empty, "TOKEN" is used.
When reverse is true, cells use background-color SGR (48;5;N) instead of foreground (38;5;N), turning each cell into a solid colored rectangle — useful for evaluating shades as label backgrounds. fgIndex then selects the text color rendered atop those colored cells: pass any 256-color SGR index (0..255), or a negative value to keep the terminal's default foreground. fgIndex is ignored when reverse is false.
Useful for picking a label color or debugging ramp choices in any consumer of governa-color.
func ShowPalette ¶
func ShowPalette()
ShowPalette prints a labeled inspection of the v1.0 palette: standard 16-color, 256-color cube, grayscale ramp, the 10 per-hue ramps, and the heat ramp. Useful for verifying terminal rendering and tuning ramp indices. Run from a real terminal so the SGR escapes render.
Types ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
build
command
build is based on an original build.sh Bash script from the source project that inspired this template.
|
build is based on an original build.sh Bash script from the source project that inspired this template. |
|
prep
command
|
|
|
rel
command
CODE-flavor library wrapper.
|
CODE-flavor library wrapper. |
|
showgrid
command
Command showgrid prints a bordered side-by-side grid of every governa-color ramp at every step, each cell rendering a sample token.
|
Command showgrid prints a bordered side-by-side grid of every governa-color ramp at every step, each cell rendering a sample token. |
|
showpalette
command
Command showpalette prints every governa-color helper plus a labeled dump of all 256-color SGR indices to stdout.
|
Command showpalette prints every governa-color helper plus a labeled dump of all 256-color SGR indices to stdout. |
|
internal
|
|
|
preptool
Package preptool stages a release: bumps version constants, inserts a CHANGELOG row, deletes completed AC files, sweeps matching AC-pointer IE lines from plan.md, runs validation builds around the write phases, and prints the canonical release command.
|
Package preptool stages a release: bumps version constants, inserts a CHANGELOG row, deletes completed AC files, sweeps matching AC-pointer IE lines from plan.md, runs validation builds around the write phases, and prints the canonical release command. |