summaryrefslogtreecommitdiff
path: root/cmd2/command_definition.py
diff options
context:
space:
mode:
Diffstat (limited to 'cmd2/command_definition.py')
-rw-r--r--cmd2/command_definition.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd2/command_definition.py b/cmd2/command_definition.py
index a235525d..115cef64 100644
--- a/cmd2/command_definition.py
+++ b/cmd2/command_definition.py
@@ -87,6 +87,7 @@ def register_command(cmd_func: Callable[['Cmd', Union['Statement', 'argparse.Nam
break
_UNBOUND_COMMANDS.append((cmd_name, cmd_func, cmd_completer, cmd_help))
+ return cmd_func
def with_default_category(category: str):
@@ -132,6 +133,12 @@ class CommandSet(object):
to perform an initialization requiring access to the Cmd object.
:param cmd: The cmd2 main application
- :return: None
"""
self._cmd = cmd
+
+ def on_unregister(self, cmd: 'Cmd'):
+ """
+ Called by ``cmd2.Cmd`` when a CommandSet is unregistered and removed.
+ :param cmd:
+ """
+ self._cmd = None