Skip to content

feat(#15): --format pretty + --color flag + new default - #16

Merged
larspohlmann merged 14 commits into
developfrom
feature/15-pretty-format
Aug 12, 2026
Merged

larspohlmann merged 14 commits into
developfrom
feature/15-pretty-format

Conversation

@larspohlmann

Copy link
Copy Markdown
Owner

Closes #15.

Summary

Adds a seventh output format, pretty — well-formatted, colored terminal output that becomes the new default when STDOUT is a TTY. The text format remains opt-in via --format text and is frozen (zero diff on TextReporter / TextReporterTest).

What's new

  • PrettyReporter — file-grouped (alphabetical), within-file line-sorted, structural typography, 64-char divider before the summary. No borders, no icons beyond FINDING/WARNING.
  • Styler seam — one method per semantic role. NullStyler (color-off) and AnsiStyler (8-color, the only src/ class that emits \e). PrettyReporter has zero color-branch logic.
  • ColorPolicy::from(string \$mode, bool \$tty, bool \$noColorSet): Styler — pure 3-input resolver. Exhaustive Q11 truth table pinned in ColorPolicyTest.
  • --color=always|auto|never (git-style, default auto) + Options::\$colorMode. NO_COLOR honored only in auto; always/never are absolute.
  • colorMode config key in phptramp.json / phptramp.dist.json (strict type + membership validation).
  • ReporterFactory::create(Options, Styler) — routes pretty through the Styler.
  • Application is the only place that reads stream_isatty(STDOUT) / getenv('NO_COLOR'). Downgrades pretty→text on non-TTY when --color=auto (the default), so pipes/CI stay plain. --color=never keeps plain pretty in a pipe; --color=always keeps colored pretty (escape hatch for less -R).
  • Default --format flipped text→pretty (TTY-gated; non-TTY downgrade keeps existing non-TTY tests green).
  • README / CHANGELOG / docs/plan.md frozen semantic / help text updated.

Architecture constraints honored

  • No second production dependency — all ANSI self-emitted, 8-color only.
  • No boolean flag params that select behaviour; color on/off lives in the injected Styler.
  • text format and its exact-string tests untouched.
  • Clean Code house style: final + readonly, few params, guard clauses, errors as exceptions.

Verification

  • composer check green: 489 tests, 1552 assertions.
  • composer infection:diff 94% MSI (gate is 80%); zero escaped mutants on PrettyReporter.php.
  • Final superpowers code review: no Critical issues; all Important findings resolved (docs reconciliation + three mutation-gap tests).

Migration

  • Pipes/CI get text automatically (the default --color=auto downgrades non-TTY pretty to text).
  • To force colored pretty into a pipe: --color=always. To force plain pretty (file-grouped, no ANSI): --color=never.
  • Pass --format text to force the old default on a TTY.

…rade docs

- Pin within-file sort to first-hop line (guards sort-by-later-hop mutant).
- Pin explain:false suppression even when trace is non-empty (guards the
  ! $this->explain guard against an && mutation).
- Add exact-byte AnsiStyler fixture proving *YOURS* routes to annotation()
  (bold-magenta) and (stored) to terminalKind() (dim-green) — pins the
  hopLine ternary against a branch swap.
- Refine CHANGELOG/README/docs/plan to state the downgrade is gated on
  --color=auto (the default): --color=never keeps plain pretty in a pipe,
  --color=always keeps colored pretty (escape hatch for less -R).
@larspohlmann
larspohlmann merged commit be43fbe into develop Aug 12, 2026
5 checks passed
@larspohlmann
larspohlmann deleted the feature/15-pretty-format branch August 12, 2026 11:45
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.

Reporting: --format pretty colored terminal output + --color flag + new default

1 participant