summaryrefslogtreecommitdiff
path: root/cmd2/command_definition.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-09-01 16:49:34 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2020-09-01 16:49:34 -0400
commit77a36b1b20b32ddca608421b8831938ada46c06c (patch)
treeac9655841762a693ee4df431782a2ddb12793c19 /cmd2/command_definition.py
parent36b0b75265942fe375545beb7d2d8a2c5f6f63c4 (diff)
downloadcmd2-git-77a36b1b20b32ddca608421b8831938ada46c06c.tar.gz
Added on_registered() callback to CommandSet
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.