# HG changeset patch # User catherine@Elli.myhome.westell.com # Date 1214665801 14400 # Node ID bb44928c38565511546e8b1cc55be549db2d2e89 # Parent dcd5d13e5603ca6cbfbba119502ad3e94e7058dd migrating to onecmd from select diff -r dcd5d13e5603 -r bb44928c3856 cmd2.py --- a/cmd2.py Sat Jun 28 10:31:12 2008 -0400 +++ b/cmd2.py Sat Jun 28 11:10:01 2008 -0400 @@ -148,6 +148,7 @@ s = '%s %s' % (shortcut, s[1:]) self.searchable = self.asEntered = s self.app = app + self.terminator_pattern = self.punctuationPattern(self.app.terminators) self.output_destination_pattern = self.punctuationPattern(['>>', '>']) self.input_source_pattern = self.punctuationPattern(['<']) self.pipe_destination_pattern = self.punctuationPattern(['|']) @@ -161,6 +162,11 @@ pattern = pyparsing.SkipTo(processed) + processed + pyparsing.restOfLine return pattern def parse(self): + termination = self.terminator_pattern.searchString(self.asEntered) + if termination: + self.terminator = termination[0][1] + if len(termination[0]) > 3: + self.terminator_suffix = termination[0][2] punctuators = ['|','>','>>','<'] punctuators.extend(self.app.terminators) punctuated = self.punctuationPattern(punctuators).searchString(self.asEntered) @@ -176,17 +182,9 @@ self.cmd, self.arg = None, None def complete(self): - terminator_finder = self.punctuationPattern(self.app.terminators) - result = terminator_finder.searchString(self.asEntered) - while not result: + while not self.terminator_pattern.searchString(self.asEntered): inp = self.app.pseudo_raw_input(self.app.continuationPrompt) self.asEntered = '%s\n%s' % (self.asEntered, inp) - result = terminator_finder.searchString(self.asEntered) - self.terminator = result[0][1] - if len(result[0]) > 3: - self.terminator_suffix = result[0][2] - else: - self.terminator_suffix = None def redirectedInput(self): inputFrom = self.input_source_pattern.searchString(self.searchable) if inputFrom: