# HG changeset patch # User catherine@dellzilla # Date 1227308188 18000 # Node ID 7e5a57df88aa67430310b72b22f2138d4384a164 # Parent 8ba5127167f5b7a8675de95cc2866a95b501fbb6 kinks in assumeComplete diff -r 8ba5127167f5 -r 7e5a57df88aa cmd2.py --- a/cmd2.py Fri Nov 21 17:05:26 2008 -0500 +++ b/cmd2.py Fri Nov 21 17:56:28 2008 -0500 @@ -355,7 +355,7 @@ multilineCommand = pyparsing.Or([pyparsing.Keyword(c, caseless=self.caseInsensitive) for c in self.multilineCommands])('multilineCommand') oneLineCommand = pyparsing.Word(pyparsing.printables)('command') afterElements = \ - pyparsing.Optional('|' + pyparsing.SkipTo(outputParser ^ stringEnd).setParseAction(lambda x: [y.strip() for y in x])('pipeTo')) + \ + pyparsing.Optional('|' + pyparsing.SkipTo(outputParser ^ stringEnd)('pipeTo')) + \ pyparsing.Optional(outputParser + pyparsing.SkipTo(stringEnd).setParseAction(lambda x: x[0].strip())('outputTo')) if self.caseInsensitive: multilineCommand.setParseAction(lambda x: x[0].lower()) @@ -420,9 +420,13 @@ return try: statement = self.parsed(line) - while statement.multilineCommand and not (statement.terminator or assumeComplete): - statement = self.parsed('%s\n%s' % (statement.raw, - self.pseudo_raw_input(self.continuationPrompt))) + if assumeComplete: + if statement.multilineCommand and not statement.terminator: + statement = self.parsed(statement.raw + self.terminators[0]) + else: + while statement.multilineCommand and not statement.terminator: + statement = self.parsed('%s\n%s' % (statement.raw, + self.pseudo_raw_input(self.continuationPrompt))) except Exception, e: print e return 0 @@ -570,7 +574,7 @@ if (val[0] == val[-1]) and val[0] in ("'", '"'): val = val[1:-1] else: - val = cast(currentVal, self.parsed(val).unterminated) + val = cast(currentVal, self.parsed(val).statement) setattr(self, paramName, val) self.stdout.write('%s - was: %s\nnow: %s\n' % (paramName, currentVal, val)) except (ValueError, AttributeError, NotSettableError), e: diff -r 8ba5127167f5 -r 7e5a57df88aa example/exampleSession.txt --- a/example/exampleSession.txt Fri Nov 21 17:05:26 2008 -0500 +++ b/example/exampleSession.txt Fri Nov 21 17:56:28 2008 -0500 @@ -77,13 +77,12 @@ OODNIGHT, GRACIEGAY OODNIGHT, GRACIEGAY OODNIGHT, GRACIEGAY -(Cmd) orate Four score and +(Cmd) orate four score and > seven releases ago > our BDFL -> blah blah blah > > -Four score and seven releases ago our BDFL blah blah blah +four score and seven releases ago our BDFL (Cmd) & look, a shortcut! look, a shortcut! (Cmd) say put this in a file > myfile.txt