diff options
author | Thiago Paiva Brito <tbrito@daitan.com> | 2020-08-28 17:27:51 -0300 |
---|---|---|
committer | Thiago Paiva Brito <tbrito@daitan.com> | 2020-08-28 17:52:17 -0300 |
commit | 28c172f70133208f3f7aacc1f45b0125ae4ec240 (patch) | |
tree | 806b0a1e7ed3b2ee8a05d7a2e8d683ebb065a6cb | |
parent | 6ac510d0cd25c8c3c76d56dd8e100ca2a6f8b962 (diff) | |
download | cliff-28c172f70133208f3f7aacc1f45b0125ae4ec240.tar.gz |
Capturing argparse errors due to problem with cmd2
The Bifrost team got an errors on their CLI that also affects OSC. When
in interactive mode, if argparse fails to parse the input due to, say,
a missing parameter, argparse by default thows a SystemExit(2), but
cmd2 doesn't like it because that could've been a signal to stop the
CLI, so it breaks the interactive session. This fix aims to bypass that
and keep the CLI running so we don't have to start it at every parameter
we forget to type in.
Change-Id: I0e2006a9625e2f8dbdbc0e5921acfb3853a06ee9
Story: 2008071
Task: 40782
-rw-r--r-- | cliff/app.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/cliff/app.py b/cliff/app.py index 3c1cdf4..a3a0657 100644 --- a/cliff/app.py +++ b/cliff/app.py @@ -21,6 +21,8 @@ import os import six import sys +import cmd2 + from cliff import _argparse from . import complete from . import help @@ -398,6 +400,8 @@ class App(object): cmd_parser = cmd.get_parser(full_name) parsed_args = cmd_parser.parse_args(sub_argv) result = cmd.run(parsed_args) + except SystemExit as ex: + raise cmd2.exceptions.Cmd2ArgparseError from ex except Exception as err: if self.options.debug: self.LOG.exception(err) |