changeset 145:0e0fc729e1a2

accept special terminators on most anything
author catherine@dellzilla
date Wed, 19 Nov 2008 16:36:45 -0500
parents 2d3477aa79d4
children 9ffb01d8876f
files cmd2.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Tue Nov 18 18:06:05 2008 -0500
+++ b/cmd2.py	Wed Nov 19 16:36:45 2008 -0500
@@ -221,7 +221,7 @@
                       + pyparsing.Optional(filenamePattern)('inputFrom')
     punctuationPattern = pipePattern ^ redirectInPattern ^ redirectOutPattern
 
-    def parsed(self, s):
+    def parsed(self, s, assumeComplete=False):
         '''
         >>> c = Cmd()
         >>> r = c.parsed('quotes "are > ignored" < inp.txt')
@@ -265,10 +265,10 @@
             result['parseable'] = result.after
         else:
             # does not catch output marks
-            if command in self.multilineCommands:
+            if (not assumeComplete) and (command in self.multilineCommands):
                 return result # don't bother with the rest, we're still collecting input
+            result['statement'] = result['unterminated'] = result.before            
             result += parseSearchResults(self.punctuationPattern, s)
-            result['statement'] = result['unterminated'] = result.before
         result += parseSearchResults(self.pipePattern, result.parseable)
         result += parseSearchResults(self.redirectInPattern, result.parseable)
         result += parseSearchResults(self.redirectOutPattern, result.parseable)