Show appropriate error message

This catches code exception if wrong arguments passed to cmd options
It also adds error message that suggests correct arguments to pass

Fixes: https://github.com/pypa/pip/issues/5616
This commit is contained in:
Nitesh Sharma 2018-07-23 21:01:53 +05:30
parent a2968978c9
commit 01a0fa5f04
2 changed files with 12 additions and 1 deletions

1
news/5644.bugfix Normal file
View File

@ -0,0 +1 @@
Show appropriate error message if invalid args passed

View File

@ -192,7 +192,17 @@ class ConfigOptionParser(CustomOptionParser):
continue
if option.action in ('store_true', 'store_false', 'count'):
val = strtobool(val)
try:
val = strtobool(val)
except ValueError:
self.error(
"#{0} is not a valid value. Valid true values"
"are {1}, {2}, {3}, {4} and valid false values"
"are {5}, {6}, {7}, {8}".format(
val, "true", "yes", "on", 1,
"false", "no", "off", 0
)
)
elif option.action == 'append':
val = val.split()
val = [self.check_default(option, key, v) for v in val]