diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-09-03 11:14:15 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-09-03 11:14:15 -0400 |
commit | 68c7750765ba9a4035775a5f46f8b37339935135 (patch) | |
tree | ec19ed703cfdcecf0bb0c4976ea377a4b0fb689c /cmd2/cmd2.py | |
parent | 72fc6bf105f4b712d5a6f991746fd2f9084893fc (diff) | |
download | cmd2-git-68c7750765ba9a4035775a5f46f8b37339935135.tar.gz |
Added CommandSet.on_unregistered()
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 8fd3d243..f3a2d88d 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -505,6 +505,7 @@ class Cmd(cmd.Cmd): 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 +513,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 +561,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 +587,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): |