diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-02-18 12:59:46 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-02-18 12:59:46 -0500 |
commit | d3deca3c99c299149a30aa3ec760dc17f8abc456 (patch) | |
tree | 58ac6df4330780cec94e854782a7bfae23c16589 /cmd2/cmd2.py | |
parent | 065536a484bb705e1e6b7971fc4c8efdb637185e (diff) | |
download | cmd2-git-d3deca3c99c299149a30aa3ec760dc17f8abc456.tar.gz |
Added apply_style to CompletionError
Simplified error class structure in argparse_completer.py
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 60d5463a..67304636 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1416,10 +1416,12 @@ class Cmd(cmd.Cmd): except IndexError: return None - except CompletionError as e: - err_str = str(e) + except CompletionError as ex: + err_str = str(ex) + # Don't print error and redraw the prompt unless the error has length if err_str: - # Don't print error and redraw the prompt unless the error has length + if ex.apply_style: + err_str = ansi.style_error(err_str) ansi.style_aware_write(sys.stdout, '\n' + err_str + '\n') rl_force_redisplay() return None |