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.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/cmd2/command_definition.py b/cmd2/command_definition.py
index 27a044bc..3c663054 100644
--- a/cmd2/command_definition.py
+++ b/cmd2/command_definition.py
@@ -53,7 +53,7 @@ class CommandSet(object):
def __init__(self):
self._cmd = None # type: Optional[cmd2.Cmd]
- def on_register(self, cmd):
+ def on_register(self, cmd) -> None:
"""
Called by cmd2.Cmd when a CommandSet is registered. Subclasses can override this
to perform an initialization requiring access to the Cmd object.
@@ -66,7 +66,14 @@ class CommandSet(object):
else:
raise CommandSetRegistrationError('This CommandSet has already been registered')
- def on_unregister(self):
+ def on_registered(self) -> None:
+ """
+ Called by cmd2.Cmd after a CommandSet is registered and all its commands have been added
+ to the CLI. Subclasses can override this to perform custom steps.
+ """
+ pass
+
+ def on_unregister(self) -> None:
"""
Called by ``cmd2.Cmd`` when a CommandSet is unregistered and removed.