1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
"""Help Tasks"""
from fabric import state
from fabric.api import task
from fabric.task_utils import crawl
from fabric.tasks import Task
@task(default=True)
def help(name=None):
"""
Display help for a given task
Options:
name - The task to display help on.
To display a list of available tasks type:
$ fab -l
To display help on a specific task type:
$ fab help:<name>
"""
if name is None:
name = 'help'
task = crawl(name, state.commands)
if isinstance(task, Task):
doc = getattr(task, '__doc__', None)
if doc is not None:
print(f'Help on {name:s}:')
print()
print(doc)
else:
print(f'No help available for {name:s}')
else:
print(f'No such task {name:s}')
print('For a list of tasks type: fab -l')
|