changeset 71:ea1697be3d00

getting suffix
author catherine@Elli.myhome.westell.com
date Wed, 25 Jun 2008 12:32:21 -0400
parents 48b0bf2e3d2e
children 6031a06bb6d7
files cmd2.py
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Mon Jun 23 22:17:28 2008 -0400
+++ b/cmd2.py	Wed Jun 25 12:32:21 2008 -0400
@@ -235,10 +235,12 @@
     
     def completedStatement(self, firstline):
         statement = firstline
-        while not self.commmand_terminator_finder(statement):
+        termination_found = self.commmand_terminator_finder(statement)        
+        while not termination_found:
             inp = self.pseudo_raw_input(self.continuationPrompt)
             statement = '%s\n%s' % (statement, inp)
-        return statement
+            termination_found = self.commmand_terminator_finder(statement)
+        return termination_found[0], termination_found[-1] 
         # assembling a list of lines and joining them at the end would be faster, 
         # but statementHasEnded needs a string arg; anyway, we're getting
         # user input and users are slow.
@@ -255,12 +257,13 @@
         """       
         command, args = self.extractCommand(line)
         statement = originalStatement = ' '.join([command, args])
+        suffix = statement
         if (not assumeComplete) and (command in self.multilineCommands):
-            statement = self.completedStatement(statement)
+            statement, suffix = self.completedStatement(statement)
         statekeeper = None
         stop = 0
 
-        inputFrom  = self.input_source_finder(statement)
+        inputFrom  = self.input_source_finder(suffix)
         if inputFrom:
             statement, source = inputFrom[0], inputFrom[-1]
             if source:
@@ -268,14 +271,14 @@
             else:
                 statement = '%s %s' % (statement, getPasteBuffer())
         
-        pipeTo = self.pipe_destination_finder(statement)
+        pipeTo = self.pipe_destination_finder(suffix)
         if pipeTo:
             statement, pipeTo = pipeTo[0], pipeTo[-1]
             statekeeper = Statekeeper(self, ('stdout',))               
             pipeTo = subprocess.Popen(pipeTo, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
             self.stdout = pipeTo.stdin
         else:  # can't pipe output AND send it to a file
-            outputTo = self.output_destination_finder(statement)
+            outputTo = self.output_destination_finder(suffix)
             if outputTo:
                 statement, destination = outputTo[0], outputTo[-1]
                 statekeeper = Statekeeper(self, ('stdout',))