Rework hooke.command.Command.handle_arguments (again :p).
authorW. Trevor King <wking@drexel.edu>
Wed, 12 May 2010 11:31:34 +0000 (07:31 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 12 May 2010 11:31:34 +0000 (07:31 -0400)
Previous implementation didn't set params[name] when
  num_provided == 0 and argument.callback != None

hooke/command.py

index 21e09b8060b51e16c2bd992b91452df4b74a45b5..5c0f1b2eacf007d7486ab9e1293459cd2357fe08 100644 (file)
@@ -162,13 +162,15 @@ class Command (object):
                        '\n  '.join(['%s: %s' % (name,value)
                                     for name,value in sorted(settings)])))
             name,value = settings[0]
-            if name != argument.name:
-                params.remove(name)
+            if num_provided == 0:
                 params[argument.name] = value
-            if argument.callback != None:
-                if num_provided > 0:
+            else:
+                if name != argument.name:
+                    params.remove(name)
+                    params[argument.name] = value
+                if argument.callback != None:
                     value = argument.callback(hooke, self, argument, value)
-                params[argument.name] = value
+                    params[argument.name] = value
             argument.validate(value)
         return params