Minor argparse improvement.
This commit is contained in:
6
lib/spack/external/argparse.py
vendored
6
lib/spack/external/argparse.py
vendored
@@ -108,6 +108,8 @@
|
||||
import sys as _sys
|
||||
import textwrap as _textwrap
|
||||
|
||||
from llnl.util.tty.colify import colified
|
||||
|
||||
from gettext import gettext as _
|
||||
|
||||
try:
|
||||
@@ -2285,8 +2287,8 @@ def _get_value(self, action, arg_string):
|
||||
def _check_value(self, action, value):
|
||||
# converted value must be one of the choices (if specified)
|
||||
if action.choices is not None and value not in action.choices:
|
||||
tup = value, ', '.join(map(repr, action.choices))
|
||||
msg = _('invalid choice: %r (choose from %s)') % tup
|
||||
cols = colified(sorted(action.choices), indent=4, tty=True)
|
||||
msg = _('invalid choice: %r choose from:\n%s') % (value, cols)
|
||||
raise ArgumentError(action, msg)
|
||||
|
||||
# =======================
|
||||
|
Reference in New Issue
Block a user