def shellcomplete_commands(outfile = None):
    """List all commands"""
    from bzrlib import commands
    from inspect import getdoc

    commands.install_bzr_command_hooks()

    if outfile is None:
        outfile = sys.stdout

    cmds = []
    for cmdname in commands.all_command_names():
        cmd = commands.get_cmd_object(cmdname)
        cmds.append((cmdname, cmd))
        for alias in cmd.aliases:
            cmds.append((alias, cmd))
    cmds.sort()
    for cmdname, cmd in cmds:
        if cmd.hidden:
            continue
        doc = getdoc(cmd)
        if doc is None:
            outfile.write(cmdname + '\n')
        else:
            doclines = doc.splitlines()
            firstline = doclines[0].lower()
            outfile.write(cmdname + ':' + firstline[0:-1] + '\n')
Example #2
0
def shellcomplete_commands(outfile=None):
    """List all commands"""
    from bzrlib import commands
    from inspect import getdoc

    commands.install_bzr_command_hooks()

    if outfile is None:
        outfile = sys.stdout

    cmds = []
    for cmdname in commands.all_command_names():
        cmd = commands.get_cmd_object(cmdname)
        cmds.append((cmdname, cmd))
        for alias in cmd.aliases:
            cmds.append((alias, cmd))
    cmds.sort()
    for cmdname, cmd in cmds:
        if cmd.hidden:
            continue
        doc = getdoc(cmd)
        if doc is None:
            outfile.write(cmdname + '\n')
        else:
            doclines = doc.splitlines()
            firstline = doclines[0].lower()
            outfile.write(cmdname + ':' + firstline[0:-1] + '\n')
Example #3
0
def shellcomplete_on_command(cmdname, outfile=None):
    cmdname = str(cmdname)

    if outfile is None:
        outfile = sys.stdout

    from inspect import getdoc
    import commands
    cmdobj = commands.get_cmd_object(cmdname)

    doc = getdoc(cmdobj)
    if doc is None:
        raise NotImplementedError("sorry, no detailed shellcomplete yet for %r" % cmdname)

    shellcomplete_on_options(cmdobj.options().values(), outfile=outfile)
    for aname in cmdobj.takes_args:
        outfile.write(aname + '\n')
Example #4
0
def shellcomplete_on_command(cmdname, outfile=None):
    cmdname = str(cmdname)

    if outfile is None:
        outfile = sys.stdout

    from inspect import getdoc
    import commands
    cmdobj = commands.get_cmd_object(cmdname)

    doc = getdoc(cmdobj)
    if doc is None:
        raise NotImplementedError(
            "sorry, no detailed shellcomplete yet for %r" % cmdname)

    shellcomplete_on_options(cmdobj.options().values(), outfile=outfile)
    for aname in cmdobj.takes_args:
        outfile.write(aname + '\n')