/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: Jelmer Vernooij
  • Date: 2020-04-05 19:11:34 UTC
  • mto: (7490.7.16 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200405191134-0aebh8ikiwygxma5
Populate the .gitignore file.

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