Beispiel #1
0
def do_help(command):
    """
    Usage: :help [COMMAND]
    List control commands or show their documentations.
    """
    command = command.strip()
    if command:
        texts = []
        for name in command.split():
            try:
                cmd = get_control_command(name.lstrip(':'))
            except AttributeError:
                console_output('Unknown control command: %s\n' % name)
            else:
                doc = [d.strip() for d in cmd.__doc__.split('\n') if d.strip()]
                texts.append('\n'.join(doc))
        if texts:
            console_output('\n\n'.join(texts))
            console_output('\n')
    else:
        names = list_control_commands()
        max_name_len = max(map(len, names))
        for i in xrange(len(names)):
            name = names[i]
            txt = ':' + name + (max_name_len - len(name) + 2) * ' '
            doc = get_control_command(name).__doc__
            txt += doc.split('\n')[2].strip() + '\n'
            console_output(txt)
Beispiel #2
0
def do_help(command):
    """
    Usage: :help [COMMAND]
    List control commands or show their documentations.
    """
    command = command.strip()
    if command:
        texts = []
        for name in command.split():
            try:
                cmd = get_control_command(name.lstrip(':'))
            except AttributeError:
                console_output('Unknown control command: %s\n' % name)
            else:
                doc = [d.strip() for d in cmd.__doc__.split('\n') if d.strip()]
                texts.append('\n'.join(doc))
        if texts:
            console_output('\n\n'.join(texts))
            console_output('\n')
    else:
        names = list_control_commands()
        max_name_len = max(map(len, names))
        for i in xrange(len(names)):
            name = names[i]
            txt = ':' + name + (max_name_len - len(name) + 2) * ' '
            doc = get_control_command(name).__doc__
            txt += doc.split('\n')[2].strip() + '\n'
            console_output(txt)
Beispiel #3
0
def complete_help(line, text):
    colon = text.startswith(':')
    text = text.lstrip(':')
    res = [cmd + ' ' for cmd in list_control_commands() if \
                           cmd.startswith(text) and ' ' + cmd + ' ' not in line]
    if colon:
        res = [':' + cmd for cmd in res]
    return res
Beispiel #4
0
def complete_help(line, text):
    colon = text.startswith(':')
    text = text.lstrip(':')
    res = [cmd + ' ' for cmd in list_control_commands() if \
                           cmd.startswith(text) and ' ' + cmd + ' ' not in line]
    if colon:
        res = [':' + cmd for cmd in res]
    return res
Beispiel #5
0
        sys.exit(1)

    updated_man_page_fd, updated_man_page_path = tempfile.mkstemp()
    updated_man_page = os.fdopen(updated_man_page_fd, 'w')

    # The first line is auto-generated as it contains the version number
    man_page.readline()
    v = '.TH "polysh" "1" "%s" "Guillaume Chazarain" "Remote shells"' % VERSION
    print >> updated_man_page, v

    for line in man_page:
        print >> updated_man_page, line,
        if 'BEGIN AUTO-GENERATED CONTROL COMMANDS DOCUMENTATION' in line:
            break

    for name in list_control_commands():
        print >> updated_man_page, '.TP'
        unstripped = get_control_command(name).__doc__.split('\n')
        lines = [l.strip() for l in unstripped]
        usage = lines[1].strip()
        print >> updated_man_page, '\\fB%s\\fR' % usage[7:]
        help_text = ' '.join(lines[2:]).replace('polysh', '\\fIpolysh\\fR')
        print >> updated_man_page, help_text.strip()

    for line in man_page:
        if 'END AUTO-GENERATED CONTROL COMMANDS DOCUMENTATION' in line:
            print >> updated_man_page, line,
            break

    for line in man_page:
        print >> updated_man_page, line,
Beispiel #6
0
        sys.exit(1)

    updated_man_page_fd, updated_man_page_path = tempfile.mkstemp()
    updated_man_page = os.fdopen(updated_man_page_fd, 'w')

    # The first line is auto-generated as it contains the version number
    man_page.readline()
    v = '.TH "polysh" "1" "%s" "Guillaume Chazarain" "Remote shells"' % VERSION
    print >> updated_man_page, v

    for line in man_page:
        print >> updated_man_page, line,
        if 'BEGIN AUTO-GENERATED CONTROL COMMANDS DOCUMENTATION' in line:
            break

    for name in list_control_commands():
        print >> updated_man_page, '.TP'
        unstripped = get_control_command(name).__doc__.split('\n')
        lines = [l.strip() for l in unstripped]
        usage = lines[1].strip()
        print >> updated_man_page, '\\fB%s\\fR' % usage[7:]
        help_text = ' '.join(lines[2:]).replace('polysh', '\\fIpolysh\\fR')
        print >> updated_man_page, help_text.strip()

    for line in man_page:
        if 'END AUTO-GENERATED CONTROL COMMANDS DOCUMENTATION' in line:
            print >> updated_man_page, line,
            break

    for line in man_page:
        print >> updated_man_page, line,