-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Colorize text formatter #134
Conversation
|
||
def rainbow | ||
@rainbow ||= Rainbow.new.tap do |rainbow| | ||
rainbow.enabled = config.text_formatter_colors && $stdout.tty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much more terse, with improved clarity, than the equivalent rubocop cop code. Nice job!
@tscheffe Thank you for your thorough code review! Please check my replies and fixup commit. I hope you will like the end result better. :) |
Everything is looking good to me! Works great! Waiting on review from @mmozuras then right? |
Thanks, Trent! @mmozuras |
@nbekirov looks good 👍 |
@mmozuras Indeed, the config toggle is not needed per se - I'll remove it. |
3409ff8
to
e6bd124
Compare
- Add Rainbow dependency - Add Colorizable mixin - Apply Colorizable to TextFormatter - location - level - Add/Update specs
e6bd124
to
1a4548b
Compare
@mmozuras I've removed the configuration, rebased, and squashed! Please let me know what do you think. 😃 |
@nbekirov amazing, thanks 👏 😄 |
This PR colorizes the text formatter to improve terminal readability when used locally.
Before
After
Configuration
The new feature is controlled via
text_formatter
:colors
property in.pronto.yml
. This is also reflected in theREADME.md
. By default it's disabled.This feature is always disabled (configuration is ignored) when not in TTY to enable file I/O redirection,
grep
, etc.N.B. I've had some hard time trying to enable it by default as there seems to be some issues with overriding truthy
ConfigFile::EMPTY
values via.pronto.yml
/ENV
settings. I'll investigate further and report back.P.S. I've left the proposed
--colored
option out as it would require a bit of a bigger refactoring to centralize the configuration and its modification. CurrentlyTEXT_FORMATTER_COLORS=true pronto run
will be available as an alternative.New dependencies
I've used Rainbow as suggested in #129.
Colorizable mixin
This is a reusable module intended to be used by any formatter that may need colorization. Its implementation is inspired by the one seen in Rubocop.
Colors and styles
The colors I've used are inspired by Rubocop as I find them to be quite nice and recognizable.
Resolves #129