forked from ungleich-public/cdist
Let config file and command line override NO_COLOR envvar
This commit is contained in:
parent
cdb0d2be41
commit
89e48734bf
1 changed files with 4 additions and 6 deletions
|
@ -256,14 +256,12 @@ class ColoredOutputOption(BooleanOption):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def translate(val):
|
def translate(val):
|
||||||
if 'NO_COLOR' in os.environ:
|
if isinstance(val, bool):
|
||||||
return False
|
|
||||||
elif isinstance(val, bool):
|
|
||||||
return val
|
return val
|
||||||
elif val == 'auto':
|
elif val in configparser.ConfigParser.BOOLEAN_STATES:
|
||||||
return sys.stdout.isatty()
|
|
||||||
else:
|
|
||||||
return configparser.ConfigParser.BOOLEAN_STATES[val]
|
return configparser.ConfigParser.BOOLEAN_STATES[val]
|
||||||
|
elif val == 'auto':
|
||||||
|
return 'NO_COLOR' not in os.environ and sys.stdout.isatty()
|
||||||
|
|
||||||
|
|
||||||
ColoredOutputOption.DEFAULT = ColoredOutputOption.translate(
|
ColoredOutputOption.DEFAULT = ColoredOutputOption.translate(
|
||||||
|
|
Loading…
Reference in a new issue