/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/shellcomplete.py

  • Committer: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from __future__ import absolute_import
18
 
 
19
17
import sys
20
18
 
21
19
 
22
 
def shellcomplete(context=None, outfile=None):
 
20
def shellcomplete(context=None, outfile = None):
23
21
    if outfile is None:
24
22
        outfile = sys.stdout
25
23
    if context is None:
26
 
        shellcomplete_commands(outfile=outfile)
 
24
        shellcomplete_commands(outfile = outfile)
27
25
    else:
28
 
        shellcomplete_on_command(context, outfile=outfile)
 
26
        shellcomplete_on_command(context, outfile = outfile)
29
27
 
30
28
 
31
29
def shellcomplete_on_command(cmdname, outfile=None):
35
33
        outfile = sys.stdout
36
34
 
37
35
    from inspect import getdoc
38
 
    from . import commands
 
36
    import commands
39
37
    cmdobj = commands.get_cmd_object(cmdname)
40
38
 
41
39
    doc = getdoc(cmdobj)
42
40
    if doc is None:
43
 
        raise NotImplementedError(
44
 
            "sorry, no detailed shellcomplete yet for %r" % cmdname)
 
41
        raise NotImplementedError("sorry, no detailed shellcomplete yet for %r" % cmdname)
45
42
 
46
43
    shellcomplete_on_options(cmdobj.options().values(), outfile=outfile)
47
44
    for aname in cmdobj.takes_args:
53
50
        short_name = opt.short_name()
54
51
        if short_name:
55
52
            outfile.write('"(--%s -%s)"{--%s,-%s}\n'
56
 
                          % (opt.name, short_name, opt.name, short_name))
 
53
                    % (opt.name, short_name, opt.name, short_name))
57
54
        else:
58
55
            outfile.write('--%s\n' % opt.name)
59
56
 
60
57
 
61
 
def shellcomplete_commands(outfile=None):
 
58
def shellcomplete_commands(outfile = None):
62
59
    """List all commands"""
63
 
    from . import commands
 
60
    import inspect
 
61
    import commands
64
62
    from inspect import getdoc
65
63
 
66
64
    commands.install_bzr_command_hooks()