Autocompletion of options works for prefixes of full command names
authorDmitriy Morozov <dmitriy@mrzv.org>
Wed, 08 Sep 2010 17:39:56 -0700
changeset 108 8befe33c55b1
parent 107 564899a22b31
child 117 e17bf1d5c289
Autocompletion of options works for prefixes of full command names
opster.py
--- a/opster.py	Wed Sep 08 17:30:13 2010 -0700
+++ b/opster.py	Wed Sep 08 17:39:56 2010 -0700
@@ -370,10 +370,14 @@
         print ' '.join(filter(lambda x: x.startswith(current), commands))
     
     # command options
-    elif cwords[0] in commands:
+    else:
+        try:
+            aliases, (cmd, opts, usage) = findcmd(cwords[0], cmdtable)
+        except AmbiguousCommand:
+            sys.exit(1) 
+
         idx = -2 if current else -1
         options = []
-        aliases, (cmd, opts, usage) = findcmd(cwords[0], cmdtable)
 
         for o in opts:
             short, long, default, help = o[:4]