You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: honor NO_COLOR and keep pipe output parseable #635
We check TTY in a few places (logo.ts already honors NO_COLOR; docs ask disables the spinner off-TTY) but human tables always use Unicode box drawing (src/output.ts + cli-table3), and elastic status prints checkmarks. No --no-color. Piped human output is not a stable TSV.
Pre-1.0, do not add a pager. Do:
Honor NO_COLOR and FORCE_COLOR everywhere we emit ANSI
Add --no-color as a global alias for NO_COLOR
When stdout is not a TTY and --json is absent, render tables as TSV (or fall back to JSON). Unicode borders and checkmarks are TTY-only
Relates to #623 (nested object rendering). This issue is the output contract, not that CAT bug.
Acceptance: NO_COLOR=1 elastic status has no ANSI and no checkmark glyphs. elastic stack es cat indices | cat is TSV or JSON, not a box table. Tests cover TTY and non-TTY.
I would like to take this after #628. Plan: honor NO_COLOR and FORCE_COLOR everywhere, add global --no-color, render TSV for piped non-TTY tables, keep stdout for data and stderr for diagnostics. Tests for TTY and non-TTY included.
Checked #689's diff against the remaining ANSI/plain-output sites. It covers src/lib/logo.ts, both experimentalBanner copies (src/docs/search.ts, src/docs/ask.ts), the spinner escape in src/docs/stream.ts, and table colour/TSV in src/output.ts. These sites are not covered by #689. They should get fixes before this issue closes:
src/docs/chat.ts:83,98: both spinners are gated on interactive (line 63), which only checks process.stdin.isTTY. Line 98 sits inside the if (interactive) block at line 85. Nothing checks stderr, so elastic docs chat 2>log still writes \r spinner frames to the file every 80 ms. feat(cli): honor NO_COLOR and render plain output when piped #689 only removes \x1b[K under NO_COLOR.
src/output.ts:48: const headers = Object.keys(rows[0]!) drops any key that first appears in a later row. feat(cli): honor NO_COLOR and render plain output when piped #689's new renderTsv copies the same pattern, so piped output loses those columns too. Fix: take the union of keys across all rows.
The colour gate is still written out by hand in several places. #689 adds colorsEnabled() in src/output.ts, and stream.ts checks NO_COLOR directly. Another option is a single src/lib/color.ts built on util.styleText(format, text, { stream }). On Node ≥22.13 it handles NO_COLOR, FORCE_COLOR and TTY detection itself. engines allows >=22.1, so the helper would need to feature-detect the stream option and fall back to colorsEnabled on older versions.
Acceptance:
elastic help environment topic describes NO_COLOR, FORCE_COLOR and --no-color for all output.
docs chat writes no spinner frames when stderr is not a TTY.
renderTable/renderTsv include every key seen in any row (test with [{a:1},{a:2,b:3}]).
Activity
onatozmenn commentedon Sep 27, 2026
I would like to take this after #628. Plan: honor NO_COLOR and FORCE_COLOR everywhere, add global --no-color, render TSV for piped non-TTY tables, keep stdout for data and stderr for diagnostics. Tests for TTY and non-TTY included.
JoshMock commentedon Oct 9, 2026
Checked #689's diff against the remaining ANSI/plain-output sites. It covers
src/lib/logo.ts, bothexperimentalBannercopies (src/docs/search.ts,src/docs/ask.ts), the spinner escape insrc/docs/stream.ts, and table colour/TSV insrc/output.ts. These sites are not covered by #689. They should get fixes before this issue closes:src/help-topics.ts:38still saysNO_COLOR ... disables color on the logo. After feat(cli): honor NO_COLOR and render plain output when piped #689, NO_COLOR applies to all output, and--no-color/FORCE_COLORshould be documented here as well.src/docs/chat.ts:83,98: both spinners are gated oninteractive(line 63), which only checksprocess.stdin.isTTY. Line 98 sits inside theif (interactive)block at line 85. Nothing checks stderr, soelastic docs chat 2>logstill writes\rspinner frames to the file every 80 ms. feat(cli): honor NO_COLOR and render plain output when piped #689 only removes\x1b[Kunder NO_COLOR.src/output.ts:48:const headers = Object.keys(rows[0]!)drops any key that first appears in a later row. feat(cli): honor NO_COLOR and render plain output when piped #689's newrenderTsvcopies the same pattern, so piped output loses those columns too. Fix: take the union of keys across all rows.The colour gate is still written out by hand in several places. #689 adds
colorsEnabled()insrc/output.ts, andstream.tschecksNO_COLORdirectly. Another option is a singlesrc/lib/color.tsbuilt onutil.styleText(format, text, { stream }). On Node ≥22.13 it handles NO_COLOR, FORCE_COLOR and TTY detection itself.enginesallows>=22.1, so the helper would need to feature-detect thestreamoption and fall back tocolorsEnabledon older versions.Acceptance:
elastic helpenvironment topic describes NO_COLOR, FORCE_COLOR and--no-colorfor all output.docs chatwrites no spinner frames when stderr is not a TTY.renderTable/renderTsvinclude every key seen in any row (test with[{a:1},{a:2,b:3}]).authored by Pi Coding Agent (Claude Opus 5.5)