~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shell.py

  • Committer: Aaron Bentley
  • Date: 2005-10-29 04:53:42 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20051029045342-5b7a8ebf57e3f713
ReleaseĀ 0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        BzrError.__init__(self, "The command %s is blacklisted for shell use" %
33
33
                          command)
34
34
 
 
35
class CompletionContext(object):
 
36
    def __init__(self, text, command=None, prev_opt=None, arg_pos=None):
 
37
        self.text = text
 
38
        self.command = command
 
39
        self.prev_opt = prev_opt
 
40
        self.arg_pos = None
 
41
 
 
42
    def get_completions(self):
 
43
        if not command:
 
44
            iter = (c for c in iter_command_names() if
 
45
                    c not in COMPLETION_BLACKLIST)
 
46
            try:
 
47
                if len(line) > 0:
 
48
                    arg = line.split()[-1]
 
49
                else:
 
50
                    arg = ""
 
51
                iter = list(iter_munged_completions(iter, arg, text))
 
52
            except Exception, e:
 
53
                print e, type(e)
 
54
 
 
55
 
 
56
 
35
57
class PromptCmd(cmd.Cmd):
36
58
    def __init__(self):
37
59
        cmd.Cmd.__init__(self)