mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
bitkeeper revision 1.1108.2.2 (40fbf4de21Jj1rHIoB288QJ0sKILVg)
Tweak xm command parsing - can now use unambiguous prefixes to identify the command. For instance: 'xm list' can be 'xm l' 'xm li' 'xm lis'.
This commit is contained in:
1 parent
13b4d9fade
commit
d477bafaa1
1 file changed
+16
-1
@@ -105,8 +105,23 @@ class Xm:
|
||||
|
||||
def getprog(self, name, val=None):
|
||||
"""Get a sub-program.
|
||||
name Name of the sub-program (or optionally, an unambiguous
|
||||
prefix of its name)
|
||||
val Default return value if no (unique) match is found
|
||||
"""
|
||||
return self.progs.get(name, val)
|
||||
|
||||
match = None
|
||||
for progname in self.progs.keys():
|
||||
if progname == name:
|
||||
match = progname
|
||||
break
|
||||
if progname.startswith(name):
|
||||
if not match:
|
||||
match = progname
|
||||
else:
|
||||
return val # name is ambiguous - bail out
|
||||
|
||||
return self.progs.get(match, val)
|
||||
|
||||
def proglist(self):
|
||||
"""Get a list of sub-programs, ordered by group.
|
||||
|
||||