-
Notifications
You must be signed in to change notification settings - Fork 129
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
Fixed --no-color flag behaviour in non-tty environments #1339
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1339 +/- ##
==========================================
- Coverage 22.39% 22.39% -0.01%
==========================================
Files 54 54
Lines 4514 4515 +1
==========================================
Hits 1011 1011
- Misses 3403 3404 +1
Partials 100 100 ☔ View full report in Codecov by Sentry. |
I'd worried only if this commit changes the default behaviour of the tool. Is it the case?
I'd let @mheap chime in, but I believe predictability is a very important feature. I'd vote against doing special handling on a case-by-case way since we should let the input define the expected behaviour. === On a side note: please check here for the convention we use for commit messages. This will help us have a consistent and clear "git story". Thanks! |
This does change the default behaviour. The expected behaviour from the issue is as follows:
There may not be a way to differentiate |
The non-tty environments had no option of getting a colorised output. This change retains the default behaviour of showing colors in tty and no colors in non-tty if no flag is passed. However, on passing the --no-color=false, non-tty environments can also get colored output. Fix #1313
27a8df2
to
ded0121
Compare
For retaining the default behaviour, I can check if the flag was passed or not before changing the value for |
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.
I didn't know about viper.IsSet
, nice!!
Good job!
This fixes issue #1313 and makes the flag behaviour consistent across tty and non-tty.
The attached image shows the changed behaviour.
Now, the non-tty output also comes up as colored by default, same as tty output. This can be overridden by passing the
--no-color
flag.I have a doubt though.
If our customers pass the deck output to a non-tty (may be a file), this can cause things to break if
--no-color
is not passed, as the colorised output may cause formatting issues in a file.Is this doubt valid?
Should I check for non-tty environments separately and handle this, if this is indeed a valid usecase?
@GGabriele @mheap