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

Allow disabling color #170

Closed
jiasli opened this issue Dec 2, 2019 · 1 comment · Fixed by #171
Closed

Allow disabling color #170

jiasli opened this issue Dec 2, 2019 · 1 comment · Fixed by #171
Assignees

Comments

@jiasli
Copy link
Member

jiasli commented Dec 2, 2019

Related to #169. Reported in Azure/azure-cli#6080. Also caused side effect of Azure/azure-cli#9903.

If stdout is redirected and CLI displays a colored error message, the color in the console can't revert back to the default which is caused by tartley/colorama#200.

Without proper a fix from Colorama, Knack should have the ability to disable color. This can be done by extending _should_enable_color by supporting env var like KNACK_ENABLE_COLOR or KNACK_DISABLE_COLOR.

knack/knack/log.py

Lines 57 to 64 in 44ee179

def _should_enable_color(self):
try:
# Color if tty stream available
if self.stream.isatty():
return True
except AttributeError:
pass
return False

@jiasli
Copy link
Member Author

jiasli commented Mar 24, 2020

Completed in #181.

@jiasli jiasli closed this as completed Mar 24, 2020
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 a pull request may close this issue.

1 participant