mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Wire in color for pre-commit. Closes #63.
This commit is contained in:
parent
8aa88c7363
commit
73e0111e38
3 changed files with 20 additions and 6 deletions
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue