summaryrefslogtreecommitdiffstats
path: root/pre_commit/color.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-08-30 11:22:57 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2020-08-30 11:22:57 +0000
commit16e677e925131974acbd67131124e11301d127b4 (patch)
treedc6734c39114c88aeeeb6b72c46b141489cd66f5 /pre_commit/color.py
parentReleasing debian version 2.6.0-1. (diff)
downloadpre-commit-16e677e925131974acbd67131124e11301d127b4.tar.xz
pre-commit-16e677e925131974acbd67131124e11301d127b4.zip
Merging upstream version 2.7.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/color.py')
-rw-r--r--pre_commit/color.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/pre_commit/color.py b/pre_commit/color.py
index eb906b7..4ddfdf5 100644
--- a/pre_commit/color.py
+++ b/pre_commit/color.py
@@ -1,3 +1,4 @@
+import argparse
import os
import sys
@@ -95,3 +96,12 @@ def use_color(setting: str) -> bool:
os.getenv('TERM') != 'dumb'
)
)
+
+
+def add_color_option(parser: argparse.ArgumentParser) -> None:
+ parser.add_argument(
+ '--color', default=os.environ.get('PRE_COMMIT_COLOR', 'auto'),
+ type=use_color,
+ metavar='{' + ','.join(COLOR_CHOICES) + '}',
+ help='Whether to use color in output. Defaults to `%(default)s`.',
+ )