Add color support to CLI table output for better readability
This PR adds color coding to the FTA CLI table output to help users quickly identify code quality issues and improve overall readability.
Changes Made
The CLI table output now displays:
-
FTA Scores: Color-coded based on score ranges
- 🟢 Green for scores ≤ 50 (good code quality)
- 🟡 Yellow for scores 50-60 (moderate issues)
- 🔴 Red for scores > 60 (needs improvement)
-
Assessment Messages: Matching colors for assessments
- "OK" → Green
- "Could be better" → Yellow
- "Needs improvement" → Red
-
Headers: White color for clear section identification
-
File and Line Count columns: Grey color for visual hierarchy
Technical Implementation
- Added
coloredcrate dependency with optional feature flag - Enhanced
comfy_tableintegration with proper ANSI color formatting - Implemented score-to-color mapping functions for consistent theming
- Created backwards-compatible output function for testing
- Removed
force_no_tty()to enable color output in terminals
Example Output
The screenshot shows the new colored output with files of varying complexity levels, making it easy to spot which files need attention at a glance.
Testing
- All existing tests continue to pass (57/57)
- Added comprehensive color validation test
- Manual testing verified across all FTA score ranges
- Backwards compatibility maintained for non-color environments
This enhancement significantly improves the user experience by providing immediate visual feedback about code quality, making the FTA tool more actionable for developers.
Original prompt
This section details on the original issue you should resolve
<issue_title>Add colour to CLI output</issue_title> <issue_description>The CLI output should make higher FTA scores (and "Assessment" messages) increasingly red (on a scale from green (low fta score) -> red (high fta score)). Also, the headings should be white, and the "File" and "Num. Lines" columns slightly grey.</issue_description>
Comments on the Issue (you are @copilot in this section)
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.