diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-05-07 16:29:59 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-05-07 16:31:17 -0400 |
commit | 6460d5707fffc725c50e0642b1e1e2edafa18d87 (patch) | |
tree | d58fff643fde105fcaeec9a7cc5a3311d95ee696 /cmd2/exceptions.py | |
parent | c50db52da00f4e544a6b3a19ee5b0f54e8503914 (diff) | |
download | cmd2-git-6460d5707fffc725c50e0642b1e1e2edafa18d87.tar.gz |
Made following changes to onecmd_plus_hooks()
1. Added SystemExit handling by warning the user it's occured and setting stop to True
2. KeyboardInterrupts won't be raised if stop is already set to True.
Diffstat (limited to 'cmd2/exceptions.py')
-rw-r--r-- | cmd2/exceptions.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cmd2/exceptions.py b/cmd2/exceptions.py index d0a922db..8a7fd81f 100644 --- a/cmd2/exceptions.py +++ b/cmd2/exceptions.py @@ -16,10 +16,10 @@ class SkipPostcommandHooks(Exception): class Cmd2ArgparseError(SkipPostcommandHooks): """ - A ``SkipPostcommandHooks`` exception for when a command fails parsing its arguments. - This is raised by argparse decorators but can also be raised by command functions. - If a command function still needs to run post command hooks when parsing fails, - just return instead of raising an exception. + A ``SkipPostcommandHooks`` exception for when a command fails to parse its arguments. + Normally argparse raises a SystemExit exception in these cases. To avoid stopping the command + loop, catch the SystemExit and raise this instead. If you still need to run post command hooks + after parsing fails, just return instead of raising an exception. """ pass |