~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shellcomplete.py

fixme note for bzr status

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
 
4
4
def shellcomplete(context=None, outfile = None):
5
 
    if outfile is None:
 
5
    if outfile == None:
6
6
        outfile = sys.stdout
7
 
    if context is None:
 
7
    if context == None:
8
8
        shellcomplete_commands(outfile = outfile)
9
9
    else:
10
10
        shellcomplete_on_command(context, outfile = outfile)
12
12
def shellcomplete_on_command(cmdname, outfile = None):
13
13
    cmdname = str(cmdname)
14
14
 
15
 
    if outfile is None:
 
15
    if outfile == None:
16
16
        outfile = sys.stdout
17
17
 
18
18
    from inspect import getdoc
20
20
    cmdobj = commands.get_cmd_object(cmdname)
21
21
 
22
22
    doc = getdoc(cmdobj)
23
 
    if doc is None:
 
23
    if doc == None:
24
24
        raise NotImplementedError("sorry, no detailed shellcomplete yet for %r" % cmdname)
25
25
 
26
26
    shellcomplete_on_option(cmdobj.takes_options, outfile = None)
28
28
        outfile.write(aname + '\n')
29
29
 
30
30
 
31
 
def shellcomplete_on_option(options, outfile=None):
32
 
    from bzrlib.option import Option
 
31
def shellcomplete_on_option(options, outfile = None):
 
32
    import commands
 
33
    
33
34
    if not options:
34
35
        return
35
 
    if outfile is None:
 
36
    
 
37
    if outfile == None:
36
38
        outfile = sys.stdout
 
39
 
37
40
    for on in options:
38
 
        for shortname, longname in Option.SHORT_OPTIONS.items():
 
41
        for shortname, longname in commands.SHORT_OPTIONS.items():
39
42
            if longname == on:
40
43
                l = '"(--' + on + ' -' + shortname + ')"{--' + on + ',-' + shortname + '}'
41
44
                break
50
53
    import commands
51
54
    from inspect import getdoc
52
55
    
53
 
    if outfile is None:
 
56
    if outfile == None:
54
57
        outfile = sys.stdout
55
58
    
56
59
    cmds = []
63
66
        if cmdclass.hidden:
64
67
            continue
65
68
        doc = getdoc(cmdclass)
66
 
        if doc is None:
 
69
        if doc == None:
67
70
            outfile.write(cmdname + '\n')
68
71
        else:
69
72
            doclines = doc.splitlines()