chiark / gitweb /
subcommand.py: Have `subcommand' pass unknown arguments to constructor.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 13 Jul 2013 15:34:40 +0000 (16:34 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 6 Apr 2014 11:22:39 +0000 (12:22 +0100)
Since it has an explicit class parameter, it should be able to pass
initargs to the class constructor.

subcommand.py

index b285915..d6d850e 100644 (file)
@@ -392,12 +392,10 @@ class SubcommandOptionParser (OP.OptionParser, object):
 ## ready to roll.
 COMMANDS = []
 
-def subcommand(name, contexts, desc, cls = Subcommand,
-               opts = [], params = [], oparams = [], rparam = None):
+def subcommand(name, contexts, desc, cls = Subcommand, *args, **kw):
   """Decorator for defining subcommands."""
   def _(func):
-    COMMANDS.append(cls(name, contexts, desc, func,
-                        opts, params, oparams, rparam))
+    COMMANDS.append(cls(name, contexts, desc, func, *args, **kw))
   return _
 
 ###----- That's all, folks --------------------------------------------------