def completeOptions(self, text, state):
# need to simplify this much more
buffer = readline.get_line_buffer()
line = readline.get_line_buffer().split()
# show all commands
if not line:
return [c + ' ' for c in self.options][state]
# account for last argument ending in a space
if self.re.match(buffer):
line.append('')
# resolve command to the implementation function
cmd = line[0].strip()
if cmd in self.options:
args = line[1:]
if args:
return False
return [cmd + ' '][state]
results = [c + ' ' for c in self.options if c.startswith(cmd)] + [None]
return results[state]
评论列表
文章目录