Skip to content

feat: add chalk colors for improved terminal UI experience#107

Merged
adithya-naik merged 9 commits into
developfrom
feature/chalk-colors
Jun 30, 2026
Merged

feat: add chalk colors for improved terminal UI experience#107
adithya-naik merged 9 commits into
developfrom
feature/chalk-colors

Conversation

@adithya-naik

@adithya-naik adithya-naik commented Jun 30, 2026

Copy link
Copy Markdown
Owner

What this PR does

Adds chalk library integration to colorize terminal output across all commands. This improves readability and gives a modern, polished feel to the CLI.

Changes

  • Added chalk as a dependency
  • Created src/utils/colors.js for centralized color management
  • Applied consistent color scheme across all commands:
    • Success messages → Green
    • Error messages → Red
    • Warnings → Yellow
    • Command output → Cyan
    • Metadata → Dim/Gray
  • Updated list, search, stats, favorite, and clear commands to use new colors

Technical notes

  • Migrated from manual ANSI escape codes to chalk for better cross-platform support
  • Category names now have unique colors (git=green, docker=blue, npm=red, etc.)
  • All lint errors fixed (branch synced with latest develop)

Checklist

  • Lint passes (npm run lint → 0 errors)
  • Synced with latest develop
  • Tested locally (all commands working with colors)
  • Ready for review

How to test

npm install
tracker list
tracker stats
tracker favorite "git status" 

Summary by CodeRabbit

  • New Features

    • Added consistent colored/styled output across command-line views and messages.
    • Improved category-specific display in list, search, stats, favorites, export, and save flows.
    • Added clearer, more readable formatting for prompts, headings, totals, and results.
  • Bug Fixes

    • Updated error, warning, and empty-state messages for more consistent feedback.
    • Refined category display and search highlighting to make command details easier to scan.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A new src/utils/colors.js module is added, wrapping Chalk with semantic color constants (success, error, warning, info, dim, bold, heading) and a getCategoryColor function. All command files (clear, export, favorite, init, list, save, search, stats) and validator.js are updated to import and use this module, replacing plain console.log strings with styled output. No logic or control flow changes.

Changes

Centralized color utility and CLI output styling

Layer / File(s) Summary
colors.js utility module
src/utils/colors.js
Introduces categoryColors map, getCategoryColor(category) with chalk.white fallback, and semantic constants (success, error, warning, info, dim, bold, heading) all exported via module.exports.
Styled output in all commands and validator
src/commands/clear.js, src/commands/export.js, src/commands/favorite.js, src/commands/init.js, src/commands/list.js, src/commands/save.js, src/commands/search.js, src/commands/stats.js, src/utils/validator.js
Each file adds a colors import and replaces plain console.log strings with colors.* calls for error, warning, success, and info states. displayCategory in list.js and per-category stat lines in stats.js also use getCategoryColor. No control flow is altered.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • adithya-naik/cmd-tracker#82: Modifies the same list.js and stats.js category/icon rendering logic that this PR also restyled with color helpers.
  • adithya-naik/cmd-tracker#96: Overlaps on the same showInitError()/showCategoryError() console message code paths in validator.js that this PR converts to colors.* calls.

Poem

🐇 Roses are chalk.red, console was plain,
I hopped through each file and styled the refrain.
getCategoryColor maps every key,
colors.success and dim — now styled with glee!
No logic was harmed in my colorful spree. 🎨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% 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
Title check ✅ Passed The title clearly matches the main change: adding Chalk-based terminal colors for the CLI UI.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/chalk-colors

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.

@sonarqubecloud

Copy link
Copy Markdown

@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

🧹 Nitpick comments (1)
src/commands/favorite.js (1)

46-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the success formatter for the add-success path.

This branch is a successful state, but it currently renders with colors.warning, which conflicts with the new semantic color scheme.

Proposed fix
-      console.log(colors.warning('\n⭐ Added to favorites: ') + command);
+      console.log(colors.success('\n⭐ Added to favorites: ') + command);
🤖 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 `@src/commands/favorite.js` around lines 46 - 48, The added-to-favorites
success branch in favorite.js is using the warning formatter instead of the
success semantic style. Update the `result.action === 'added'` path in the
`favorite` command to use the success formatter from `colors` for the “Added to
favorites” message, keeping the category line unchanged so the add-success state
matches the new color scheme.
🤖 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 `@src/commands/init.js`:
- Around line 128-135: The .gitignore update logic in init.js is appending the
tracker ignore content twice when the file already exists, causing duplicate
comment blocks and entries. Update the code around the existing
fs.appendFileSync calls so the tracker block is written only once: keep the
combined cmd-tracker personal data entries in entriesToAdd/trackerEntry and
remove the extra append of trackerEntry, or otherwise ensure the .gitignore
content is assembled and appended as a single block in the init flow.
- Around line 148-149: The fallback `.gitignore` guidance is out of sync with
the files this initializer now treats as local-only. Update the manual
instruction in the init flow that logs via colors.warning/colors.info so it
tells users to ignore `.tracker/` as well as tracker-export.json and
tracker-export.csv whenever the automatic .gitignore update fails.

In `@src/commands/search.js`:
- Around line 79-82: The highlight logic in search.js is building a RegExp
directly from the user-provided searchTerm, which can throw or misbehave on
regex metacharacters. Update the command highlighting in the search flow to
escape searchTerm before passing it to new RegExp, while keeping the existing
item.command replace behavior and colors.warning.bold highlighting intact.

---

Nitpick comments:
In `@src/commands/favorite.js`:
- Around line 46-48: The added-to-favorites success branch in favorite.js is
using the warning formatter instead of the success semantic style. Update the
`result.action === 'added'` path in the `favorite` command to use the success
formatter from `colors` for the “Added to favorites” message, keeping the
category line unchanged so the add-success state matches the new color scheme.
🪄 Autofix (Beta)

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

Run ID: d981a5e5-17a4-4363-82e1-988967d74fdb

📥 Commits

Reviewing files that changed from the base of the PR and between ffbd0e7 and 729e7f4.

📒 Files selected for processing (10)
  • src/commands/clear.js
  • src/commands/export.js
  • src/commands/favorite.js
  • src/commands/init.js
  • src/commands/list.js
  • src/commands/save.js
  • src/commands/search.js
  • src/commands/stats.js
  • src/utils/colors.js
  • src/utils/validator.js

Comment thread src/commands/init.js
Comment thread src/commands/init.js
Comment thread src/commands/search.js
@adithya-naik adithya-naik merged commit d198dda into develop Jun 30, 2026
4 checks passed
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.

1 participant