/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 breezy/shellcomplete.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-08-23 01:15:41 UTC
  • mfrom: (7520.1.4 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200823011541-nv0oh7nzaganx2qy
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/389690

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import sys
18
18
 
19
19
 
20
 
def shellcomplete(context=None, outfile = None):
 
20
def shellcomplete(context=None, outfile=None):
21
21
    if outfile is None:
22
22
        outfile = sys.stdout
23
23
    if context is None:
24
 
        shellcomplete_commands(outfile = outfile)
 
24
        shellcomplete_commands(outfile=outfile)
25
25
    else:
26
 
        shellcomplete_on_command(context, outfile = outfile)
 
26
        shellcomplete_on_command(context, outfile=outfile)
27
27
 
28
28
 
29
29
def shellcomplete_on_command(cmdname, outfile=None):
33
33
        outfile = sys.stdout
34
34
 
35
35
    from inspect import getdoc
36
 
    import commands
 
36
    from . import commands
37
37
    cmdobj = commands.get_cmd_object(cmdname)
38
38
 
39
39
    doc = getdoc(cmdobj)
40
40
    if doc is None:
41
 
        raise NotImplementedError("sorry, no detailed shellcomplete yet for %r" % cmdname)
 
41
        raise NotImplementedError(
 
42
            "sorry, no detailed shellcomplete yet for %r" % cmdname)
42
43
 
43
44
    shellcomplete_on_options(cmdobj.options().values(), outfile=outfile)
44
45
    for aname in cmdobj.takes_args:
50
51
        short_name = opt.short_name()
51
52
        if short_name:
52
53
            outfile.write('"(--%s -%s)"{--%s,-%s}\n'
53
 
                    % (opt.name, short_name, opt.name, short_name))
 
54
                          % (opt.name, short_name, opt.name, short_name))
54
55
        else:
55
56
            outfile.write('--%s\n' % opt.name)
56
57
 
57
58
 
58
 
def shellcomplete_commands(outfile = None):
 
59
def shellcomplete_commands(outfile=None):
59
60
    """List all commands"""
60
 
    import inspect
61
 
    import commands
 
61
    from . import commands
62
62
    from inspect import getdoc
63
63
 
64
64
    commands.install_bzr_command_hooks()