-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add possibility to write ANSI color escape codes when the console output is redirected #47935
Conversation
Tagging subscribers to this area: Issue DetailsThis introduces an opt-in mechanism to allow writing ANSI color escape codes even when the console output is redirected. To enable ANSI color codes, the Fixes #33980
|
Nice! Thanks for doing this! |
Direction for #33980 needs to be resolved first. @KathleenDollard, please chime in. |
I'm sorry, but I must still disagree that this is the correct direction. CI providers already have a standard mechanism that they use to communicate that you're running in a CI environment. For better or worse, this is the status quo; tools detect the CI environment and adapt their behavior accordingly. By introducing a novel variable, that means that you're expecting the CI systems to start setting it. I don't mean to sound negative or difficult, but we will not, if for the practical reason that there are many more applications in the world than there are CI systems and there's already an established mechanism where the apps check to see if they're running in CI. We simply can't set dozens or hundreds (or more?) of environment variables. (I apologize if your change is orthogonal to CI systems, but that was certainly my interest in and understanding of #33980.) |
Yes, this change is absolutely orthogonal to CI systems. The modification proposed here is at the Unix Console platform abstraction layer and should certainly not have anything remotely related to CI environment variables. By the way, I just rebased on the |
0239f02
to
0798728
Compare
0798728
to
0dbfbb3
Compare
Since #33980 still has some open topics, I'm going to mark this PR as a Draft until those details are solidified. |
Draft Pull Request was automatically closed for inactivity. Please let us know if you'd like to reopen it. |
|
Pretty damn sad. This seems like a really nice thing to have and an easy win. |
0dbfbb3
to
829989d
Compare
@0xced, I pushed a commit to your branch that:
@dotnet/area-system-console, please review. |
@stephentoub this looks good. Thank you! My only question is if converting the stored int to a bool on every single console write would be a perf hit over just storing the calculated bool value? |
You're welcome.
No, it won't be measurable. It's just I do need to delete an erroneous assert that's the cause of the test failures. |
829989d
to
339f800
Compare
@stephentoub when |
Thanks. I can fix the test for when in CI for that. I don't think there's a product issue here, though; if you don't have TERM set, you can set it. Agreed? Or is there a larger concern I'm not aware of? |
Yes, it can be set. I don't know if it is expected to be set in the CI environment variables |
…put is redirected This introduces an opt-in mechanism to allow writing ANSI color escape codes even when the console output is redirected. To enable ANSI color codes, the `DOTNET_CONSOLE_ANSI_COLOR` environment variable must be set to `true` (case insensitive) or `1`. Fixes dotnet#33980
339f800
to
5fb9588
Compare
This introduces an opt-in mechanism to allow writing ANSI color escape codes even when the console output is redirected.
To enable ANSI color codes, the
DOTNET_CONSOLE_ANSI_COLOR
environment variable must be set totrue
(case insensitive) or1
.Fixes #33980