/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-05-06 02:13:25 UTC
  • mfrom: (7490.7.21 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200506021325-awbmmqu1zyorz7sj
Merge 3.1 branch.

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
 
    import commands
 
36
    from . 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("sorry, no detailed shellcomplete yet for %r" % cmdname)
 
41
        raise NotImplementedError(
 
42
            "sorry, no detailed shellcomplete yet for %r" % cmdname)
44
43
 
45
44
    shellcomplete_on_options(cmdobj.options().values(), outfile=outfile)
46
45
    for aname in cmdobj.takes_args:
52
51
        short_name = opt.short_name()
53
52
        if short_name:
54
53
            outfile.write('"(--%s -%s)"{--%s,-%s}\n'
55
 
                    % (opt.name, short_name, opt.name, short_name))
 
54
                          % (opt.name, short_name, opt.name, short_name))
56
55
        else:
57
56
            outfile.write('--%s\n' % opt.name)
58
57
 
59
58
 
60
 
def shellcomplete_commands(outfile = None):
 
59
def shellcomplete_commands(outfile=None):
61
60
    """List all commands"""
62
61
    from . import commands
63
62
    from inspect import getdoc