Actually, pass plugin instance to Command.__init__.
[hooke.git] / hooke / plugin / config.py
index 7cb4ef5af8caf816621e09324ef2c6b6b3da4ac7..82ba03844a013160a603796880269875ba5e8499 100644 (file)
@@ -31,8 +31,8 @@ from ..plugin import Builtin
 class ConfigPlugin (Builtin):
     def __init__(self):
         super(ConfigPlugin, self).__init__(name='config')
 class ConfigPlugin (Builtin):
     def __init__(self):
         super(ConfigPlugin, self).__init__(name='config')
-        self._commands = [GetCommand(), SetCommand(), PrintCommand()]
-        self._setup_commands()
+        self._commands = [GetCommand(self), SetCommand(self),
+                          PrintCommand(self)]
 
 
 # Define common or complicated arguments
 
 
 # Define common or complicated arguments
@@ -55,11 +55,11 @@ Configuration option to act on.
 class GetCommand (Command):
     """Get the current value of a configuration option.
     """
 class GetCommand (Command):
     """Get the current value of a configuration option.
     """
-    def __init__(self):
+    def __init__(self, plugin):
         super(GetCommand, self).__init__(
             name='get config',
             arguments=[SectionArgument, OptionArgument],
         super(GetCommand, self).__init__(
             name='get config',
             arguments=[SectionArgument, OptionArgument],
-            help=self.__doc__)
+            help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
        outqueue.put(hooke.config.get(params['section'], params['option']))
 
     def _run(self, hooke, inqueue, outqueue, params):
        outqueue.put(hooke.config.get(params['section'], params['option']))
@@ -73,7 +73,7 @@ class SetCommand (Command):
     noticed by the target classes unless the configuration is reloaded.
     This reloading may cause problems in poorly written UIs.
     """
     noticed by the target classes unless the configuration is reloaded.
     This reloading may cause problems in poorly written UIs.
     """
-    def __init__(self):
+    def __init__(self, plugin):
         super(SetCommand, self).__init__(
             name='set config',
             arguments=[
         super(SetCommand, self).__init__(
             name='set config',
             arguments=[
@@ -82,7 +82,7 @@ class SetCommand (Command):
                     name='value', type='string', optional=False,
                     help='Value to set.'),
                 ],
                     name='value', type='string', optional=False,
                     help='Value to set.'),
                 ],
-            help=self.__doc__)
+            help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
        hooke.config.set(params['section'], params['option'], params['value'])
 
     def _run(self, hooke, inqueue, outqueue, params):
        hooke.config.set(params['section'], params['option'], params['value'])
@@ -95,9 +95,9 @@ class SetCommand (Command):
 class PrintCommand (Command):
     """Get the current value of a configuration option.
     """
 class PrintCommand (Command):
     """Get the current value of a configuration option.
     """
-    def __init__(self):
+    def __init__(self, plugin):
         super(PrintCommand, self).__init__(
         super(PrintCommand, self).__init__(
-            name='print config', help=self.__doc__)
+            name='print config', help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
         out = StringIO()
 
     def _run(self, hooke, inqueue, outqueue, params):
         out = StringIO()