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.py35
1 files changed, 2 insertions, 33 deletions
diff --git a/cmd2/command_definition.py b/cmd2/command_definition.py
index 22d8915e..86f1151a 100644
--- a/cmd2/command_definition.py
+++ b/cmd2/command_definition.py
@@ -18,36 +18,6 @@ except ImportError: # pragma: no cover
pass
-def _partial_passthru(func: Callable, *args, **kwargs) -> functools.partial:
- """
- Constructs a partial function that passes arguments through to the wrapped function.
- Must construct a new type every time so that each wrapped function's __doc__ can be copied correctly.
-
- :param func: wrapped function
- :param args: positional arguments
- :param kwargs: keyword arguments
- :return: partial function that exposes attributes of wrapped function
- """
- def __getattr__(self, item):
- return getattr(self.func, item)
-
- def __setattr__(self, key, value):
- return setattr(self.func, key, value)
-
- def __dir__(self) -> Iterable[str]:
- return dir(self.func)
-
- passthru_type = type('PassthruPartial' + func.__name__,
- (functools.partial,),
- {
- '__getattr__': __getattr__,
- '__setattr__': __setattr__,
- '__dir__': __dir__,
- })
- passthru_type.__doc__ = func.__doc__
- return passthru_type(func, *args, **kwargs)
-
-
def with_default_category(category: str):
"""
Decorator that applies a category to all ``do_*`` command methods in a class that do not already
@@ -78,8 +48,7 @@ class CommandSet(object):
``with_default_category`` can be used to apply a default category to all commands in the CommandSet.
- ``do_``, ``help_``, and ``complete_`` functions differ only in that they're now required to accept
- a reference to ``cmd2.Cmd`` as the first argument after self.
+ ``do_``, ``help_``, and ``complete_`` functions differ only in that self is the CommandSet instead of the cmd2 app
"""
def __init__(self):
@@ -98,7 +67,7 @@ class CommandSet(object):
else:
raise CommandSetRegistrationError('This CommandSet has already been registered')
- def on_unregister(self, cmd):
+ def on_unregister(self):
"""
Called by ``cmd2.Cmd`` when a CommandSet is unregistered and removed.