Skip to content

cmdio: add Bold, Faint, Italic, Underline, Magenta helpers#5360

Merged
pietern merged 2 commits into
mainfrom
cmdio-bold-dim
May 28, 2026
Merged

cmdio: add Bold, Faint, Italic, Underline, Magenta helpers#5360
pietern merged 2 commits into
mainfrom
cmdio-bold-dim

Conversation

@pietern
Copy link
Copy Markdown
Contributor

@pietern pietern commented May 28, 2026

Expose Go-callable wrappers for SGR styles already present as constants in libs/cmdio/color.go: Bold (1), Faint (2), Italic (3), Underline (4), and Magenta (35).

Helpers are named after the SGR descriptor of their constant — so ansiFaintFaint, matching the rest of the file. Doc comments use the SGR table phrasing so Bold and Faint read as paired intensities.

Also adds faint and underline bindings to RenderFuncMap.

Related to #5223.

This pull request and its description were written by Isaac.

Add two helpers to the existing Red/Green/etc. set:

- Bold renders text in bold (\x1b[1m). The ansiBold constant already
  existed in color.go but wasn't exposed as a helper.
- Dim renders text in dim/faint intensity (\x1b[2m). The ansiDim
  constant is new.

Both gate on the same SupportsStdoutColor capability check as the
existing color helpers, so they degrade to plain text in the same
conditions.

These are useful for command output where colored emphasis would be
distracting but visual hierarchy still helps — e.g. bold IDs and
command names, dim secondary metadata.

Co-authored-by: Isaac
@pietern pietern temporarily deployed to test-trigger-is May 28, 2026 08:33 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is May 28, 2026 08:33 — with GitHub Actions Inactive
@eng-dev-ecosystem-bot
Copy link
Copy Markdown
Collaborator

eng-dev-ecosystem-bot commented May 28, 2026

Commit: 9177849

Run: 26567392884

Align helpers with the constants and SGR nomenclature they reference:

- Rename the previously-added Dim helper to Faint. The underlying
  constant is ansiFaint (SGR 2, "Faint, decreased intensity, or dim").
  Helpers in this file are named after the SGR descriptor of their
  constant (Bold/Red/Green/…), so Faint matches that pattern. The
  earlier addition introduced ansiDim as a second constant for the same
  byte sequence; drop that and route Faint through ansiFaint, removing
  the duplicate.

- Add Italic, Underline, and Magenta helpers. Constants for these
  already lived in color.go (and Magenta even had a template binding
  via RenderFuncMap), but no Go-callable wrapper. They round out the
  basic-16 styles likely to be useful for CLI emphasis without going
  to the full fatih/color kitchen sink.

- Add faint and underline bindings to RenderFuncMap so templates can
  reach them on the same footing as bold and italic.

- Align the Bold and Faint doc comments with the SGR table phrasing
  ("increased intensity" / "decreased intensity") so the two read as
  paired intensities, matching the spec.

The Hi* set is intentionally left as-is (only HiBlack and HiBlue) —
those have real callers in libs/apps/logstream and the warehouse
picker; the other six bright variants have none.

Co-authored-by: Isaac
@pietern pietern temporarily deployed to test-trigger-is May 28, 2026 09:47 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is May 28, 2026 09:47 — with GitHub Actions Inactive
@pietern pietern changed the title cmdio: add Bold and Dim color helpers cmdio: add Bold, Faint, Italic, Underline, Magenta helpers May 28, 2026
@pietern pietern requested a review from simonfaltum May 28, 2026 09:50
@pietern pietern merged commit c8ea3a8 into main May 28, 2026
24 of 25 checks passed
@pietern pietern deleted the cmdio-bold-dim branch May 28, 2026 10:52
denik pushed a commit that referenced this pull request May 28, 2026
Expose Go-callable wrappers for SGR styles already present as constants
in `libs/cmdio/color.go`: `Bold` (1), `Faint` (2), `Italic` (3),
`Underline` (4), and `Magenta` (35).

Helpers are named after the SGR descriptor of their constant — so
`ansiFaint` → `Faint`, matching the rest of the file. Doc comments use
the SGR table phrasing so `Bold` and `Faint` read as paired intensities.

Also adds `faint` and `underline` bindings to `RenderFuncMap`.

Related to #5223.

This pull request and its description were written by Isaac.
@eng-dev-ecosystem-bot
Copy link
Copy Markdown
Collaborator

Commit: c8ea3a8

Run: 26570346159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants