From 3126878dd403329122a7157275de81b036c2e638 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Mon, 29 Jun 2009 14:59:41 +0100 Subject: [PATCH] GenericMain, handle ParameterError from _ParseArgs Before this case was not covered, and printed a stack trace. Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/cli.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/cli.py b/lib/cli.py index 6afea96b6..9773842a8 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -747,7 +747,13 @@ def GenericMain(commands, override=None, aliases=None): if aliases is None: aliases = {} - func, options, args = _ParseArgs(sys.argv, commands, aliases) + try: + func, options, args = _ParseArgs(sys.argv, commands, aliases) + except errors.ParameterError, err: + result, err_msg = FormatError(err) + ToStderr(err_msg) + return 1 + if func is None: # parse error return 1 -- GitLab