diff options
Diffstat (limited to 'cmd2/command_definition.py')
-rw-r--r-- | cmd2/command_definition.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd2/command_definition.py b/cmd2/command_definition.py index 1858c80b..22d8915e 100644 --- a/cmd2/command_definition.py +++ b/cmd2/command_definition.py @@ -6,6 +6,7 @@ import functools from typing import Callable, Iterable, Optional, Type from .constants import COMMAND_FUNC_PREFIX +from .exceptions import CommandSetRegistrationError # Allows IDEs to resolve types without impacting imports at runtime, breaking circular dependency issues try: # pragma: no cover @@ -92,7 +93,10 @@ class CommandSet(object): :param cmd: The cmd2 main application :type cmd: cmd2.Cmd """ - self._cmd = cmd + if self._cmd is None: + self._cmd = cmd + else: + raise CommandSetRegistrationError('This CommandSet has already been registered') def on_unregister(self, cmd): """ |