Skip to content

feat: honor NO_COLOR and keep pipe output parseable #635

Description

@margaretjgu

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
  • Keep stdout = data, stderr = diagnostics (audit docs / status / extensions)

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.

Activity

  1. added
    enhancement
    on Sep 14, 2026
  2. onatozmenn commented on Sep 27, 2026

    @onatozmenn
    Contributor

    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.

  3. JoshMock commented on Oct 9, 2026

    @JoshMock
    Member

    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:

    1. src/help-topics.ts:38 still says NO_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_COLOR should be documented here as well.
    2. 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.
    3. 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}]).

    authored by Pi Coding Agent (Claude Opus 5.5)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions