Commit 98ccd216 authored by ∞'s avatar 💻

Improved support for command rename

parent 303e06a2
......@@ -4,7 +4,8 @@ from .introspection import Callable
def command(**config):
def wrap(cb):
if 'cli2' not in cb.__dict__:
cb.cli2 = Callable(cb.__name__, cb, **config)
name = config.pop('name', cb.__name__)
cb.cli2 = Callable(name, cb, **config)
else:
cb.cli2.__dict__.update(config)
return cb
......
......@@ -75,7 +75,8 @@ class BaseGroup(collections.OrderedDict):
def add_commands(self, *callbacks):
for cb in callbacks:
self[cb.__name__] = Callable.for_callback(cb)
callable = Callable.for_callback(cb)
self[callable.name] = callable
return self
def add_group(self, name, *args, **kwargs):
......
command: cli2 help
retcode: 1
stdout:
cli2 is like click but as laxist as docopts.
cli2 makes your python callbacks work on CLI too !
cli2 provides sub-commands to introspect python modules or callables docstrings
or to execute callables or help working with cli2 itself.
help Get help for a command.
run Execute a python callback on the command line.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment