Actually, pass plugin instance to Command.__init__.
[hooke.git] / hooke / plugin / system.py
index 185fa8e44cd312b5bbbedf6e00e82b165af253ca..8a0923597bab30dceb0fbd6ba8a2c9ca0f2141a1 100644 (file)
@@ -34,15 +34,14 @@ class SystemPlugin (Builtin):
     def __init__(self):
         super(SystemPlugin, self).__init__(name='system')
         self._commands = [
-            ListDirectoryCommand(), GetWorkingDirectoryCommand(),
-            ChangeDirectoryCommand(), SystemCommand()]
-        self._setup_commands()
+            ListDirectoryCommand(self), GetWorkingDirectoryCommand(self),
+            ChangeDirectoryCommand(self), SystemCommand(self)]
 
 
 class ListDirectoryCommand (Command):
     """List the files in a directory.
     """
-    def __init__(self):
+    def __init__(self, plugin):
         super(ListDirectoryCommand, self).__init__(
             name='ls', aliases=['dir'],
             arguments=[
@@ -53,7 +52,7 @@ Path to the directory whose contents get listed.  Defaults to the
 current working directory.
 """.strip()),
 ],
-            help=self.__doc__)
+            help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
        outqueue.put('\n'.join(sorted(os.listdir(params['path']))))
@@ -61,9 +60,9 @@ current working directory.
 class GetWorkingDirectoryCommand (Command):
     """Get the current working directory.
     """
-    def __init__(self):
+    def __init__(self, plugin):
         super(GetWorkingDirectoryCommand, self).__init__(
-            name='cwd', aliases=['pwd'], help=self.__doc__)
+            name='cwd', aliases=['pwd'], help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
        outqueue.put(os.getcwd())
@@ -71,7 +70,7 @@ class GetWorkingDirectoryCommand (Command):
 class ChangeDirectoryCommand (Command):
     """Change the current working directory.
     """
-    def __init__(self):
+    def __init__(self, plugin):
         super(ChangeDirectoryCommand, self).__init__(
             name='cd',
             arguments=[
@@ -82,7 +81,7 @@ Path of the directory to change into.  Default to the user's home
 directory.
 """.strip()),
 ],
-            help=self.__doc__)
+            help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
         os.chdir(os.path.expanduser(params['path']))
@@ -90,7 +89,7 @@ directory.
 class SystemCommand (Command):
     """Execute a system command and report the output.
     """
-    def __init__(self):
+    def __init__(self, plugin):
         super(SystemCommand, self).__init__(
             name='system',
             arguments=[
@@ -100,7 +99,7 @@ class SystemCommand (Command):
 Command line to execute.
 """.strip()),
 ],
-            help=self.__doc__)
+            help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
         p = subprocess.Popen(