Improve --color help with argparse metavar

This commit is contained in:
Anthony Sottile 2016-03-08 16:34:09 -08:00
parent 77a1a29c12
commit eb6da4ae10
2 changed files with 13 additions and 8 deletions

View file

@ -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 (