Added auto-completion for becommands/set property names.
authorW. Trevor King <wking@drexel.edu>
Tue, 2 Dec 2008 16:12:56 +0000 (11:12 -0500)
committerW. Trevor King <wking@drexel.edu>
Tue, 2 Dec 2008 16:12:56 +0000 (11:12 -0500)
becommands/set.py

index 1103b7bf7c1fcfd89fda05a1900409ecd34ae5ae..b8a125e6040562a17d070d3b4a7f064451d98188 100644 (file)
@@ -44,7 +44,7 @@ def execute(args, test=False):
     """
     parser = get_parser()
     options, args = parser.parse_args(args)
-    cmdutil.default_complete(options, args, parser)
+    complete(options, args, parser)
     if len(args) > 2:
         raise cmdutil.UsageError, "Too many arguments"
     bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
@@ -95,3 +95,15 @@ To unset a setting, set it to "none".
 
 def help():
     return get_parser().help_str() + longhelp
+
+def complete(options, args, parser):
+    for option, value in cmdutil.option_value_pairs(options, parser):
+        if value == "--complete":
+            # no argument-options at the moment, so this is future-proofing
+            raise cmdutil.GetCompletions()
+    for pos,value in enumerate(args):
+        if value == "--complete":
+            if pos == 0: # first positional argument is a setting name
+                props = bugdir.BugDir.settings_properties
+                raise cmdutil.GetCompletions(props)
+            raise cmdutil.GetCompletions() # no positional arguments for list