/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: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

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