~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shell.py

  • Committer: Aaron Bentley
  • Date: 2005-10-27 06:14:53 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20051027061453-3063e99e7ef854be
Got support for option completion

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
            self.tree = None
104
104
 
105
105
    def do_help(self, line):
106
 
        Help()(line)
 
106
        self.default("help "+line)
107
107
 
108
108
    def default(self, line):
109
109
        args = line.split()
150
150
        :param endidx: The end of the text in the line
151
151
        :type endidx: int
152
152
        """
153
 
        try:
154
 
            (cmd, args, foo) = self.parseline(line)
155
 
            command_obj=find_command(cmd)
 
153
        (cmd, args, foo) = self.parseline(line)
 
154
        try:
 
155
            command_obj = get_cmd_object(cmd)
 
156
        except BzrError:
 
157
            command_obj = None
 
158
        try:
156
159
            if command_obj is not None:
157
 
                return command_obj.complete(args.split(), text)
158
 
            elif not self.fake_aba.is_command(cmd) and \
159
 
                cmdutil.is_tla_command(cmd):
160
 
                iter = cmdutil.iter_supported_switches(cmd)
161
 
                if len(args) > 0:
162
 
                    arg = args.split()[-1]
163
 
                else:
164
 
                    arg = ""
165
 
                if arg.startswith("-"):
166
 
                    return list(cmdutil.iter_munged_completions(iter, arg, 
167
 
                                                                text))
168
 
                else:
169
 
                    return list(cmdutil.iter_munged_completions(
170
 
                        cmdutil.iter_file_completions(arg), arg, text))
171
 
 
172
 
 
 
160
                opts = []
 
161
                for option_name, option in command_obj.options().items():
 
162
                    opts.append("--" + option_name)
 
163
                    short_name = option.short_name()
 
164
                    if short_name:
 
165
                        opts.append("-" + short_name)
 
166
                q = list(iter_munged_completions(opts, args, text))
 
167
                return list(iter_munged_completions(opts, args, text))
173
168
            elif cmd == "cd":
174
169
                if len(args) > 0:
175
170
                    arg = args.split()[-1]