diff options
author | Eric Lin <anselor@gmail.com> | 2020-07-21 17:18:38 -0400 |
---|---|---|
committer | anselor <anselor@gmail.com> | 2020-08-04 13:38:08 -0400 |
commit | c05d2b0480f284a83dfe868b1aad3d780174c289 (patch) | |
tree | ac3cb591b694718c7865e602181e870435f2ecf8 /cmd2/command_definition.py | |
parent | 372676d479dff8bb07f9361deddd63b17ce7c9d3 (diff) | |
download | cmd2-git-c05d2b0480f284a83dfe868b1aad3d780174c289.tar.gz |
Removed support for functions outside of CommandSets
Diffstat (limited to 'cmd2/command_definition.py')
-rw-r--r-- | cmd2/command_definition.py | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/cmd2/command_definition.py b/cmd2/command_definition.py index d9925969..0645de2a 100644 --- a/cmd2/command_definition.py +++ b/cmd2/command_definition.py @@ -16,11 +16,6 @@ try: # pragma: no cover except ImportError: # pragma: no cover pass -_REGISTERED_COMMANDS = {} # type: Dict[str, Callable] -""" -Registered command tuples. (command, ``do_`` function) -""" - def _partial_passthru(func: Callable, *args, **kwargs) -> functools.partial: """ @@ -52,26 +47,6 @@ def _partial_passthru(func: Callable, *args, **kwargs) -> functools.partial: return passthru_type(func, *args, **kwargs) -def register_command(cmd_func: Callable): - """ - Decorator that allows an arbitrary function to be automatically registered as a command. - If there is a ``help_`` or ``complete_`` function that matches this command, that will also be registered. - - :param cmd_func: Function to register as a cmd2 command - :type cmd_func: Callable[[cmd2.Cmd, Union[Statement, argparse.Namespace]], None] - :return: - """ - assert cmd_func.__name__.startswith(COMMAND_FUNC_PREFIX), 'Command functions must start with `do_`' - - cmd_name = cmd_func.__name__[len(COMMAND_FUNC_PREFIX):] - - if cmd_name not in _REGISTERED_COMMANDS: - _REGISTERED_COMMANDS[cmd_name] = cmd_func - else: - raise KeyError('Command ' + cmd_name + ' is already registered') - return cmd_func - - def with_default_category(category: str): """ Decorator that applies a category to all ``do_*`` command methods in a class that do not already |