Skip to content

feat: CLI Polish - Color Themes, Verbose Mode, and Terminal UX - #96

Closed
naheel0 wants to merge 1 commit into
BeyteFlow:mainfrom
naheel0:feat/cli-themes-verbose
Closed

naheel0 wants to merge 1 commit into
BeyteFlow:mainfrom
naheel0:feat/cli-themes-verbose

Conversation

@naheel0

@naheel0 naheel0 commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #54

Adds color themes, verbose diagnostic mode, and overall CLI polish to ErrLens.

Changes

New: lib/themes.js

  • 5 built-in color themes: default, minimal, high-contrast, dracula, monokai
  • Each theme defines colors for border, title, labels, fix markers, and more

esolveTheme() and isValidTheme() helpers for safe lookup

Updated: �in/index.js

  • --theme global flag — pick any built-in theme
  • --verbose global flag — show MATCH, LENGTH, KEY per error
  • Theme validation with clear error on invalid input
  • Both flags flow through to ormatError()

Updated: lib/formatter.js

  • Accepts { theme, verbose } options object
  • Uses theme colors for all chalk calls (border, labels, fix markers, etc.)
  • Verbose mode appends match metadata inside the box

Updated: lib/auto.js and lib/injector.js

  • Read ERRLENS_THEME and ERRLENS_VERBOSE env vars
  • Runtime injection now supports themes without CLI flags

Updated: README.md

  • Documented --theme, --verbose, and env var options
  • Added Color Themes section with theme comparison table
  • Added Verbose Mode section
  • Updated Quick Start, Key Features, and Project Structure

Testing

All existing functionality verified:

  • --json output unchanged
  • --lang multilingual output unchanged
  • All 5 themes render without errors
  • --verbose adds diagnostic fields
  • Invalid theme shows available options
  • errlens run and errlens analyze both work with new flags

Summary by CodeRabbit

  • New Features

    • Added configurable color themes: default, minimal, high-contrast, Dracula, and Monokai.
    • Added --theme and --verbose CLI options.
    • Added environment variable support for theme and verbose settings.
    • Verbose output now includes additional error-matching and metadata details.
    • Applied selected themes consistently to formatted errors, startup messages, and fallback output.
  • Bug Fixes

    • Invalid theme names are rejected before commands run.
    • Preserved structured JSON output and existing error exit behavior.
  • Documentation

    • Expanded usage guidance with theme names, verbose mode, environment variables, CLI examples, and output details.

- Add lib/themes.js with 5 built-in themes: default, minimal, high-contrast, dracula, monokai
- Add --theme <name> global flag for switching color themes
- Add --verbose flag for extra diagnostic info (MATCH, LENGTH, KEY)
- Update formatter.js to accept theme and verbose options
- Support ERRLENS_THEME and ERRLENS_VERBOSE env vars for runtime injection
- Update README with new CLI options, theme docs, and verbose mode
- All existing --json and --lang flags remain fully functional
@naheel0
naheel0 requested a review from jaseel0 as a code owner August 8, 2026 18:35
Copilot AI lite review requested due to automatic review settings August 8, 2026 18:35
@github-actions github-actions Bot added documentation Improvements or additions to documentation core cli labels Aug 8, 2026
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

ErrLens adds five color themes and verbose diagnostics. The CLI accepts --theme and --verbose, while runtime handlers use environment variables. Formatting, validation, JSON behavior, fallback output, and README usage documentation are updated.

Changes

Theme and verbose output

Layer / File(s) Summary
Theme definitions and formatted output
lib/themes.js, lib/formatter.js
Defines five themes. Applies theme-specific styles and optional match metadata to formatted errors.
CLI theme and verbose options
bin/index.js, README.md
Adds --theme and --verbose to run and analyze, validates theme names, and passes formatting settings to matches.
Runtime configuration and documentation
lib/auto.js, lib/injector.js, README.md
Loads theme and verbose settings from environment variables and applies them to automatic error handling and fallback output. Documents the new options and themes.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant ThemeResolver
  participant Formatter
  CLI->>ThemeResolver: Validate and resolve --theme
  CLI->>Formatter: Format error with theme and verbose options
  Formatter->>ThemeResolver: Resolve formatting theme
  ThemeResolver-->>Formatter: Return theme styles
  Formatter-->>CLI: Return formatted output
Loading

Possibly related PRs

Suggested reviewers: jaseel0

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary changes: color themes, verbose mode, and terminal UX improvements.
Linked Issues check ✅ Passed The changes address issue #54 by adding themes, verbose output, formatting improvements, JSON support, and README documentation.
Out of Scope Changes check ✅ Passed All changes are related to the CLI output, formatting, runtime configuration, themes, or documentation objectives in issue #54.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bin/index.js`:
- Around line 117-120: Update bin/index.js sites 117-120 and 167-179 to resolve
themeName within each command action and replace fixed Chalk styling with the
selected theme’s headerText, unknownText, and rawText styles; apply headerText
to the analysis header and the appropriate fallback styles to no-match and raw
output paths.

In `@lib/auto.js`:
- Around line 13-15: Update the uncaughtException handler to normalize thrown
objects using their stack string before falling back to message or String(err),
matching the err.stack handling used by lib/injector.js. Ensure the resulting
stack text is passed to findError instead of "[object Object]".

In `@README.md`:
- Line 115: Update the `--theme <name>` Color Themes link so its target resolves
correctly: either remove the broken fragment and use a valid link target, or add
a stable `color-themes` anchor associated with the Color Themes heading.
Preserve the documented navigation to that section.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b3ee983b-c5e2-4ef9-a993-dbd675748dd1

📥 Commits

Reviewing files that changed from the base of the PR and between 0bdefff and 67afae1.

📒 Files selected for processing (6)
  • README.md
  • bin/index.js
  • lib/auto.js
  • lib/formatter.js
  • lib/injector.js
  • lib/themes.js

Comment thread bin/index.js
Comment on lines 117 to +120
console.log(
chalk.red.bold("\n❌ Crash detected (No known fix in database):")
chalk.red.bold(
"\n❌ Crash detected (No known fix in database):"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Apply the selected theme to CLI fallback output.

themeName reaches formatError, but these CLI paths still use fixed Chalk colors. Resolve the theme in each command action and use headerText, unknownText, and rawText.

  • bin/index.js#L117-L120: Replace the fixed no-match error style with the selected theme’s fallback styles.
  • bin/index.js#L167-L179: Replace the fixed analysis header and no-match styles with the selected theme’s header and fallback styles.
📍 Affects 1 file
  • bin/index.js#L117-L120 (this comment)
  • bin/index.js#L167-L179
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bin/index.js` around lines 117 - 120, Update bin/index.js sites 117-120 and
167-179 to resolve themeName within each command action and replace fixed Chalk
styling with the selected theme’s headerText, unknownText, and rawText styles;
apply headerText to the analysis header and the appropriate fallback styles to
no-match and raw output paths.

Comment thread lib/auto.js
Comment on lines 13 to 15
process.on("uncaughtException", (err) => {
// Use the message for the search, guard against non-Error throws
const msg = (err && err.message) ? err.message : String(err);
const msg = err && err.message ? err.message : String(err);
const { count, matches } = findError(msg);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use the stack string for object errors.

If code throws { stack: "TypeError: ..." }, this handler passes "[object Object]" to findError. lib/injector.js already searches err.stack. Use the same normalization here.

Proposed fix
-  const msg = err && err.message ? err.message : String(err);
+  const msg =
+    err !== null && typeof err === "object"
+      ? err.stack || err.message || String(err)
+      : String(err ?? "unknown error");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
process.on("uncaughtException", (err) => {
// Use the message for the search, guard against non-Error throws
const msg = (err && err.message) ? err.message : String(err);
const msg = err && err.message ? err.message : String(err);
const { count, matches } = findError(msg);
process.on("uncaughtException", (err) => {
const msg =
err !== null && typeof err === "object"
? err.stack || err.message || String(err)
: String(err ?? "unknown error");
const { count, matches } = findError(msg);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/auto.js` around lines 13 - 15, Update the uncaughtException handler to
normalize thrown objects using their stack string before falling back to message
or String(err), matching the err.stack handling used by lib/injector.js. Ensure
the resulting stack text is passed to findError instead of "[object Object]".

Comment thread README.md
| Flag | Description |
|------|-------------|
| `--json` | Output raw JSON (no colors, no boxes) — perfect for CI/CD pipelines |
| `--theme <name>` | Pick a color theme (see [Color Themes](#-color-themes) below) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the Color Themes link target.

The #-color-themes fragment does not resolve to the heading at Line 196. Remove the fragment link or add a stable color-themes anchor.

Proposed fix
-| `--theme <name>` | Pick a color theme (see [Color Themes](`#-color-themes`) below) |
+| `--theme <name>` | Pick a color theme (see the Color Themes section below) |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| `--theme <name>` | Pick a color theme (see [Color Themes](#-color-themes) below) |
| `--theme <name>` | Pick a color theme (see the Color Themes section below) |
🧰 Tools
🪛 markdownlint-cli2 (0.23.2)

[warning] 115-115: Link fragments should be valid

(MD051, link-fragments)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 115, Update the `--theme <name>` Color Themes link so its
target resolves correctly: either remove the broken fragment and use a valid
link target, or add a stable `color-themes` anchor associated with the Color
Themes heading. Preserve the documented navigation to that section.

Source: Linters/SAST tools

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves ErrLens’ CLI/terminal user experience by introducing configurable color themes, a verbose diagnostics mode, and corresponding updates across CLI entrypoints, runtime injection helpers, and documentation.

Changes:

  • Added a new lib/themes.js module with built-in theme definitions plus resolveTheme() / isValidTheme() helpers.
  • Extended CLI (bin/index.js) and runtime helpers (lib/auto.js, lib/injector.js) to support --theme, --verbose, and ERRLENS_THEME / ERRLENS_VERBOSE.
  • Updated lib/formatter.js to style output via theme tokens and optionally include verbose match metadata; refreshed README accordingly.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
README.md Documents new --theme / --verbose flags, env vars, and theme list.
lib/themes.js Introduces theme registry and lookup/validation helpers.
lib/formatter.js Applies theme-based chalk styling and adds verbose metadata rendering.
lib/auto.js Adds env-driven theme/verbose support for automatic crash analysis output.
lib/injector.js Adds env-driven theme/verbose support for runtime injection handlers.
bin/index.js Adds global --theme / --verbose flags and validates theme names before formatting.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread README.md
| Flag | Description |
|------|-------------|
| `--json` | Output raw JSON (no colors, no boxes) — perfect for CI/CD pipelines |
| `--theme <name>` | Pick a color theme (see [Color Themes](#-color-themes) below) |
Comment thread README.md
Comment on lines +241 to +244
Verbose output adds:
- **MATCH:** the exact substring that triggered the database lookup
- **LENGTH:** character count of the match phrase
- **KEY:** the internal database key used
Comment thread lib/themes.js
Comment on lines +3 to +4
const chalkImport = require("chalk");
const chalk = chalkImport.default || chalkImport;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli core documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🎨 CLI Polish: Improve ErrLens Terminal Output & User Experience

2 participants