Skip to content
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

[Core] Allow disabling color #12601

Merged
merged 1 commit into from
Mar 16, 2020
Merged

[Core] Allow disabling color #12601

merged 1 commit into from
Mar 16, 2020

Conversation

jiasli
Copy link
Member

@jiasli jiasli commented Mar 16, 2020

Fix #6080, #9903, which are eventually caused by tartley/colorama#200

This PR requires microsoft/knack#171

Azure CLI can now disable color by

  • Setting AZURE_CORE_NO_COLOR environment variable to True
  • Using config
    [core]
    no_color=True
    

This PR removes unnecessary Colorama initializations as this is done centrally by Knack. Some command module still initializes Colorama by itself but that won't cause issue. We can gradually remove them in the future.

Whether color should be enabled can now be retrieved at cli_ctx.enable_color. Using this field, the string literal of these two sentences are changed so that they can be shown without color.

For more specific examples, use: az find "az vm list"

Please let us know how we are doing: https://aka.ms/clihats

@jiasli jiasli changed the base branch from dev to knack-adoption March 16, 2020 12:53
@jiasli jiasli merged commit 54aba72 into Azure:knack-adoption Mar 16, 2020
@jiasli jiasli mentioned this pull request Mar 16, 2020
jiasli added a commit that referenced this pull request Mar 20, 2020
* Allow disabling color (#12601)

* Support --only-show-errors (#12544)

* Add experimental tag (#12543)

* Move yaml output to Knack (#12603)
@jiasli jiasli deleted the no-color branch April 16, 2020 16:19
NVolcz added a commit to NVolcz/azure-sdk-for-python that referenced this pull request Jun 27, 2020
The Azure CLI supports colored output by using colorama which resets the color
after execution by printing "[0m" if the terminal supports color. This can in
some cases cause the AzureCliCredential to fail for example when developing
in PyCharm: Azure/azure-cli#9903
Azure CLI allows color output to be disabled by setting the environment
variable:AZURE_CORE_NO_COLOR.

The PR in azure-cli: Azure/azure-cli#12601
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Console colors do not always revert back to default
1 participant