Merge "Show Missing Argument Error raised by Argparse"

This commit is contained in:
Jenkins 2016-04-01 11:11:07 +00:00 committed by Gerrit Code Review
commit 48ccff578e
1 changed files with 7 additions and 0 deletions

View File

@ -281,6 +281,13 @@ class CategoryParser(argparse.ArgumentParser):
def error(self, message):
self.print_help(sys.stderr)
if message.startswith("argument") and message.endswith("is required"):
# NOTE(pirsriva) Argparse will currently raise an error
# message for only 1 missing argument at a time i.e. in the
# error message it WILL NOT LIST ALL the missing arguments
# at once INSTEAD only 1 missing argument at a time
missing_arg = message.split()[1]
print(_("Missing argument:\n%s") % missing_arg)
sys.exit(2)