direct-io.hg

changeset 14335:d09da90db166

Improve xm shell tab completion.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Sat Mar 10 16:38:18 2007 +0000 (2007-03-10)
parents 7e66858aa811
children 4e47dc3a6de8
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Sat Mar 10 14:57:11 2007 +0000
     1.2 +++ b/tools/python/xen/xm/main.py	Sat Mar 10 16:38:18 2007 +0000
     1.3 @@ -25,6 +25,7 @@ import atexit
     1.4  import cmd
     1.5  import os
     1.6  import pprint
     1.7 +import readline
     1.8  import shlex
     1.9  import sys
    1.10  import re
    1.11 @@ -558,6 +559,10 @@ class Shell(cmd.Cmd):
    1.12              for f in res:
    1.13                  setattr(Shell, 'do_' + f, self.default)
    1.14  
    1.15 +    def preloop(self):
    1.16 +        cmd.Cmd.preloop(self)
    1.17 +        readline.set_completer_delims(' ')
    1.18 +
    1.19      def default(self, line):
    1.20          words = shlex.split(line)
    1.21          if len(words) > 0 and words[0] == 'xm':
    1.22 @@ -577,9 +582,9 @@ class Shell(cmd.Cmd):
    1.23          return False
    1.24  
    1.25      def completedefault(self, text, line, begidx, endidx):
    1.26 -        cmd = line.split(' ')[0]
    1.27 -        clas, func = cmd.split('.')
    1.28 -        if begidx != len(cmd) + 1 or \
    1.29 +        words = shlex.split(line[:begidx])
    1.30 +        clas, func = words[0].split('.')
    1.31 +        if len(words) > 1 or \
    1.32             func.startswith('get_by_') or \
    1.33             func == 'get_all':
    1.34              return []