Skip to content

[terminal] Improve TerminalTable and PrintUtilities: color options, row separators, printToTerminal()#5787

Open
iclanton wants to merge 8 commits intomicrosoft:mainfrom
iclanton:terminal-table-improvements
Open

[terminal] Improve TerminalTable and PrintUtilities: color options, row separators, printToTerminal()#5787
iclanton wants to merge 8 commits intomicrosoft:mainfrom
iclanton:terminal-table-improvements

Conversation

@iclanton
Copy link
Copy Markdown
Member

Summary

Adds several improvements to @rushstack/terminal:

  • TerminalTable: Fixes a bug where horizontal separator lines were rendered even when their fill character was set to ''. Adds row separators between data rows. Adds borderColor and headingColor styling options. Adds a printToTerminal(terminal) convenience method.
  • PrintUtilities.printMessageInBox: Adds borderColor and messageColor styling options via a new IPrintMessageInBoxOptions interface, which is now exported from the package. The previous boxWidth positional parameter is preserved as a deprecated overload; callers should migrate to passing boxWidth via the options object.

Details

The borderColor and headingColor options on TerminalTable accept a (text: string) => string function (e.g. Colorize.cyan). Border separator lines are pre-colorized once rather than applying color on every cell render, so the color escape sequence wraps the entire line.

The deprecated printMessageInBox(message, terminal, boxWidth?) overload is preserved for backwards compatibility. The new primary overload is printMessageInBox(message, terminal, options?). TSDoc {@label} and numeric overload selectors are used so the @deprecated notice links unambiguously to the new overload.

How it was tested

Unit tests were added for all new features and the bug fix, using Jest snapshots normalized via AnsiEscape.formatForTests so that ANSI color codes appear as readable tokens (e.g. [cyan]...[default]).

iclanton and others added 8 commits April 18, 2026 15:26
…orizontal lines on fill char

- Render horizontal separators between data rows (same chars as the
  header/body separator), matching the visual convention of bordered tables
- Fix renderSeparator to return undefined when fillChar is empty, preventing
  malformed lines like ├┼┤ when only corner/junction chars are set
- Add test cases for >2 columns, single row, header-only, and empty fillChar

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ze test snapshots

- Add borderColor option: a styling function applied to all border/gridline
  characters (horizontal separator lines colored as a whole, vertical chars
  pre-colorized once before rendering)
- Add headingColor option: a styling function applied to header cell text only
- Refactor getLines() to pre-compute separator lines and styled vertical chars
  so rendering functions contain no color logic
- Add expectSnapshot() helper in tests using AnsiEscape.formatForTests so
  snapshot files show readable tokens like [cyan]/[bold] instead of raw escapes
- Add tests for borderColor, headingColor, and their combination

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ssageInBox

- Add IPrintMessageInBoxOptions with borderColor and messageColor styling
  functions, matching the pattern used by TerminalTable
- Add tests for both options and their combination, including the banner
  (wide-content) fallback layout
- Fix validateOutput to measure visual width via AnsiEscape.removeCodes so
  ANSI escape codes don't inflate the length check

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…verload references

- Export IPrintMessageInBoxOptions from the package entry point
- Add JSDoc for the boxWidth option
- Fix @example snippets to use the new 3-arg signature
- Use {@Label WITH_OPTIONS} and (printMessageInBox:1) selector to unambiguously reference the primary overload
- Update tests to use the options-based API

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

1 participant