예제 #1
0
파일: main.py 프로젝트: gitjacky/fabric
def list_commands():
    """
    Print all found commands/tasks, then exit. Invoked with -l/--list.
    """
    print("Available commands:\n")
    # Want separator between name, description to be straight col
    max_len = reduce(lambda a, b: max(a, len(b)), commands.keys(), 0)
    sep = '  '
    trail = '...'
    names = sorted(commands.keys())
    for name in names:
        output = None
        # Print first line of docstring
        func = commands[name]
        if func.__doc__:
            lines = filter(None, func.__doc__.splitlines())
            first_line = lines[0].strip()
            # Truncate it if it's longer than N chars
            size = 75 - (max_len + len(sep) + len(trail))
            if len(first_line) > size:
                first_line = first_line[:size] + trail
            output = name.ljust(max_len) + sep + first_line
        # Or nothing (so just the name)
        else:
            output = name
        print(indent(output))
    sys.exit(0)
예제 #2
0
파일: main.py 프로젝트: astraw/fabric
def list_commands():
    """
    Print all found commands/tasks, then exit. Invoked with -l/--list.
    """
    print("Available commands:\n")
    # Want separator between name, description to be straight col
    max_len = reduce(lambda a, b: max(a, len(b)), commands.keys(), 0)
    sep = '  '
    trail = '...'
    names = sorted(commands.keys())
    for name in names:
        output = None
        # Print first line of docstring
        func = commands[name]
        if func.__doc__:
            lines = filter(None, func.__doc__.splitlines())
            first_line = lines[0].strip()
            # Truncate it if it's longer than N chars
            size = 75 - (max_len + len(sep) + len(trail))
            if len(first_line) > size:
                first_line = first_line[:size] + trail
            output = name.ljust(max_len) + sep + first_line
        # Or nothing (so just the name)
        else:
            output = name
        print(indent(output))
    sys.exit(0)
예제 #3
0
파일: fabfile.py 프로젝트: zbrdge/woven
def _run_tests(key=''):
    #Get a list of functions from fabric
    tests = commands.keys()
    for t in tests:
        if key:
            test_prefix = 'test_' + key + '_'
        else:
            test_prefix = 'test_'
        if test_prefix in t and len(t) > 10:
            print string.upper(t)
            commands[t]()
            print string.upper(t), 'COMPLETE'
예제 #4
0
파일: fabfile.py 프로젝트: depleater/woven
def _run_tests(key=''):
    # Get a list of functions from Fabric.
    tests = commands.keys()
    for t in tests:
        if key:
            test_prefix = 'test_' + key + '_'
        else:
            test_prefix = 'test_'
        if test_prefix in t and len(t) > 10:
            print string.upper(t)
            commands[t]()
            print string.upper(t), 'COMPLETE'
예제 #5
0
파일: main.py 프로젝트: marcelor/fabric
def list_commands(pattern=None):
    """
    Print all found commands/tasks, then exit. Invoked with -l/--list.
    Receives an optional regexp pattern to be used to filter the commands.
    """
    print("Available commands:\n")
    if pattern:
        # If a pattern was given we filter the commands using it
        # Check if pattern is a valid regexp
        try:
            regexp = re.compile(pattern)
        except:
            abort("%s is not a valid regular expression." % pattern)
        matching_keys = [ k for k in commands.keys() if regexp.match(k) ]
    else:
        matching_keys = commands.keys()
    # Want separator between name, description to be straight col
    max_len = reduce(lambda a, b: max(a, len(b)), matching_keys, 0)
    sep = '  '
    trail = '...'
    names = sorted(matching_keys)
    for name in names:
        output = None
        # Print first line of docstring
        func = commands[name]
        if func.__doc__:
            lines = filter(None, func.__doc__.splitlines())
            first_line = lines[0].strip()
            # Truncate it if it's longer than N chars
            size = 75 - (max_len + len(sep) + len(trail))
            if len(first_line) > size:
                first_line = first_line[:size] + trail
            output = name.ljust(max_len) + sep + first_line
        # Or nothing (so just the name)
        else:
            output = name
        print(indent(output))
    sys.exit(0)
예제 #6
0
파일: main.py 프로젝트: jbrownbridge/fabric
def list_commands(docstring):
    """
    Print all found commands/tasks, then exit. Invoked with ``-l/--list.``

    If ``docstring`` is non-empty, it will be printed before the task list.
    """
    if docstring:
        trailer = "\n" if not docstring.endswith("\n") else ""
        print(docstring + trailer)
    print("Available commands:\n")
    # Want separator between name, description to be straight col
    max_len = reduce(lambda a, b: max(a, len(b)), commands.keys(), 0)
    sep = '  '
    trail = '...'
    for name in _command_names():
        output = None
        # Print first line of docstring
        func = commands[name]
        if hasattr(func, '__hide__'):
            continue
        name = name.replace('_', '-')
        if func.__doc__:
            lines = filter(None, func.__doc__.splitlines())
            first_line = lines[0].strip()
            # Truncate it if it's longer than N chars
            size = 75 - (max_len + len(sep) + len(trail))
            if len(first_line) > size:
                first_line = first_line[:size] + trail
            output = name.ljust(max_len) + sep + first_line
        # Or nothing (so just the name)
        else:
            output = name
        print(indent(output))
    print
    if 'stages' in env:
        print 'Available environments:'
        print
        for stage in env.stages:
            print '    %s' % stage
        print
    call_hooks('listing.display')
    sys.exit(0)
예제 #7
0
def list_commands(docstring):
    """
    Print all found commands/tasks, then exit. Invoked with ``-l/--list.``

    If ``docstring`` is non-empty, it will be printed before the task list.
    """
    if docstring:
        trailer = "\n" if not docstring.endswith("\n") else ""
        print(docstring + trailer)
    print("Available commands:\n")
    # Want separator between name, description to be straight col
    max_len = reduce(lambda a, b: max(a, len(b)), commands.keys(), 0)
    sep = '  '
    trail = '...'
    for name in _command_names():
        output = None
        # Print first line of docstring
        func = commands[name]
        if hasattr(func, '__hide__'):
            continue
        name = name.replace('_', '-')
        if func.__doc__:
            lines = filter(None, func.__doc__.splitlines())
            first_line = lines[0].strip()
            # Truncate it if it's longer than N chars
            size = 75 - (max_len + len(sep) + len(trail))
            if len(first_line) > size:
                first_line = first_line[:size] + trail
            output = name.ljust(max_len) + sep + first_line
        # Or nothing (so just the name)
        else:
            output = name
        print(indent(output))
    print
    if 'stages' in env:
        print 'Available environments:'
        print
        for stage in env.stages:
            print '    %s' % stage
        print
    call_hooks('listing.display')
    sys.exit(0)
예제 #8
0
파일: main.py 프로젝트: jbrownbridge/fabric
def _command_names():
    return sorted(commands.keys())
예제 #9
0
def _command_names():
    return sorted(commands.keys())