summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-09-03 23:21:39 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2020-09-03 23:21:39 -0400
commitde0261325a91dfdbe1571135ce078a978a2aaad8 (patch)
treea57ce89e0465aaa3ed2feb46aef359fe18c07071 /cmd2/cmd2.py
parentdf703af969219665b7d672025bf9b26f75a76285 (diff)
parent1054dda76b87d9f7f77311d8d804c1017b668996 (diff)
downloadcmd2-git-de0261325a91dfdbe1571135ce078a978a2aaad8.tar.gz
Merge branch 'master' into 2.0
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 730b0934..29f01a99 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -504,7 +504,9 @@ class Cmd(cmd.Cmd):
self._installed_command_sets.append(cmdset)
self._register_subcommands(cmdset)
+ cmdset.on_registered()
except Exception:
+ cmdset.on_unregister()
for attrib in installed_attributes:
delattr(self, attrib)
if cmdset in self._installed_command_sets:
@@ -512,7 +514,7 @@ class Cmd(cmd.Cmd):
if cmdset in self._cmd_to_command_sets.values():
self._cmd_to_command_sets = \
{key: val for key, val in self._cmd_to_command_sets.items() if val is not cmdset}
- cmdset.on_unregister()
+ cmdset.on_unregistered()
raise
def _install_command_function(self, command: str, command_wrapper: Callable, context=''):
@@ -560,6 +562,7 @@ class Cmd(cmd.Cmd):
"""
if cmdset in self._installed_command_sets:
self._check_uninstallable(cmdset)
+ cmdset.on_unregister()
self._unregister_subcommands(cmdset)
methods = inspect.getmembers(
@@ -585,7 +588,7 @@ class Cmd(cmd.Cmd):
if hasattr(self, HELP_FUNC_PREFIX + cmd_name):
delattr(self, HELP_FUNC_PREFIX + cmd_name)
- cmdset.on_unregister()
+ cmdset.on_unregistered()
self._installed_command_sets.remove(cmdset)
def _check_uninstallable(self, cmdset: CommandSet):