From 28c172f70133208f3f7aacc1f45b0125ae4ec240 Mon Sep 17 00:00:00 2001 From: Thiago Paiva Brito Date: Fri, 28 Aug 2020 17:27:51 -0300 Subject: 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 --- cliff/app.py | 4 ++++ 1 file changed, 4 insertions(+) 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) -- cgit v1.2.1