Wire in color for pre-commit. Closes #63.

This commit is contained in:
Anthony Sottile 2014-04-05 19:31:31 -07:00
parent 8aa88c7363
commit 73e0111e38
3 changed files with 20 additions and 6 deletions

View file

@ -6,6 +6,9 @@ GREEN = '\033[42m'
NORMAL = '\033[0m'
class InvalidColorSetting(ValueError): pass
def format_color(text, color, use_color):
"""Format text with color.
@ -26,6 +29,9 @@ def use_color(setting):
Args:
setting - Either `auto`, `always`, or `never`
"""
if setting not in ('auto', 'always', 'never'):
raise InvalidColorSetting(setting)
return (
setting == 'always' or
(setting == 'auto' and sys.stdout.isatty())