Skip to content

Allow disabling color #170

@jiasli

Description

@jiasli

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions