mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Improve --color help with argparse metavar
This commit is contained in:
parent
77a1a29c12
commit
eb6da4ae10
2 changed files with 13 additions and 8 deletions
|
|
@ -27,13 +27,16 @@ def format_color(text, color, use_color_setting):
|
|||
return u'{0}{1}{2}'.format(color, text, NORMAL)
|
||||
|
||||
|
||||
COLOR_CHOICES = ('auto', 'always', 'never')
|
||||
|
||||
|
||||
def use_color(setting):
|
||||
"""Choose whether to use color based on the command argument.
|
||||
|
||||
Args:
|
||||
setting - Either `auto`, `always`, or `never`
|
||||
"""
|
||||
if setting not in ('auto', 'always', 'never'):
|
||||
if setting not in COLOR_CHOICES:
|
||||
raise InvalidColorSetting(setting)
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue