~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shellcomplete.py

  • Committer: Robert Collins
  • Date: 2005-08-25 12:46:42 UTC
  • mfrom: (1116)
  • mto: (974.1.50) (1185.1.10) (1092.3.1)
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: robertc@robertcollins.net-20050825124642-45ed1cd74db10370
merge from mpool

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
    from inspect import getdoc
19
19
    import commands
20
 
    cmdobj = commands.get_cmd_object(cmdname)
 
20
    context, cmdclass = commands.get_cmd_class(cmdname)
21
21
 
22
 
    doc = getdoc(cmdobj)
 
22
    doc = getdoc(cmdclass)
23
23
    if doc == None:
24
24
        raise NotImplementedError("sorry, no detailed shellcomplete yet for %r" % cmdname)
25
25
 
26
 
    shellcomplete_on_option(cmdobj.takes_options, outfile = None)
27
 
    for aname in cmdobj.takes_args:
28
 
        outfile.write(aname + '\n')
29
 
 
30
 
 
31
 
def shellcomplete_on_option(options, outfile=None):
32
 
    from bzrlib.option import Option
 
26
    shellcomplete_on_option(cmdclass.takes_options, outfile = None)
 
27
    for aname in cmdclass.takes_args:
 
28
            outfile.write(aname + '\n')
 
29
 
 
30
 
 
31
def shellcomplete_on_option(options, outfile = None):
 
32
    import commands
 
33
    
33
34
    if not options:
34
35
        return
 
36
    
35
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