-
Notifications
You must be signed in to change notification settings - Fork 96
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
Allow disabling color #171
Conversation
@jiasli Should we consider upgrading knack version for the change? |
Yes. But let's test it first. We will bump the version when other PRs are merged. |
the change will disable color output from az cli totally? |
Yes, Colorama won't be initialized with |
…tdout multiple times
|
The user can either call If the user runs |
Fixes #170, #169. Also reported in Azure/azure-cli#6080 and causes side effect of Azure/azure-cli#9903.
If
stdout
is redirected and CLI displays a colored output, the color in the console can't revert back to the default because Colorama only resets color instdout
, but notstderr
(tracked at tartley/colorama#200, tartley/colorama#218). This is affecting pip as well: pypa/pip#6354 and pip uses--no-color
to disable coloring pypa/pip#4739. Azure CLI will add this option too.Without proper a fix from Colorama, Knack can now
{CLI}_CORE_NO_COLOR
environment variable.The PR removes Colorma from
out_file
with a Colorma stream and generates colorized output like jsoncself.stream
with a Colorma stream and generates colorized logsStatusTag
self.stream.isatty()
is removed because Colorama has its own mechanism to detect tty and treat PyCharm as a tty: https://github.com/tartley/colorama/blob/405b982f39efeaf697d3e2a6b90f9b913b38e97d/colorama/ansitowin32.py#L45To test,