Moved index command from hooke_cli -> hooke.plugin.playlist.IndexCommand.
authorW. Trevor King <wking@drexel.edu>
Wed, 12 May 2010 18:59:04 +0000 (14:59 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 12 May 2010 18:59:04 +0000 (14:59 -0400)
hooke/hooke_cli.py
hooke/plugin/playlist.py

index 4a5aca333f1e99dfaf5ec3864eda918b3715e301..d3d19eadbb78b89f7f31571f293dd3f7bda52749 100644 (file)
@@ -216,13 +216,3 @@ If the curve is not in the current playlist, it politely asks if we want to add
                     self.do_plot(0)
 
                 item_not_found=0
-
-
-    def do_index(self,args):
-        '''
-        INDEX
-        Prints the index of the current curve in the list
-        -----
-        Syntax: index
-        '''
-        print self.pointer+1, 'of', len(self.current_list)
index da2c927428e168525b5542b649ca82ea8b213d2a..6b16a9448aeafc58a97c2a6c59990d3fa969fd18 100644 (file)
@@ -91,6 +91,22 @@ Index of target curve.
     def _run(self, hooke, inqueue, outqueue, params):
        params['playlist'].jump(params['index'])
 
+class IndexCommand (Command):
+    """Print the index of the current curve.
+
+    The first curve has index 0.
+    """
+    def __init__(self):
+        super(IndexCommand, self).__init__(
+            name='curve index',
+            arguments=[
+                PlaylistArgument,
+                ],
+            help=self.__doc__)
+
+    def _run(self, hooke, inqueue, outqueue, params):
+       outqueue.put(params['playlist']._index)
+
 class SaveCommand (Command):
     """Save a playlist.
     """