File: help.py

package info (click to toggle)
circuits 3.2.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,980 kB
  • sloc: python: 17,583; javascript: 3,226; makefile: 100
file content (39 lines) | stat: -rw-r--r-- 867 bytes parent folder | download | duplicates (2)
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')