Skip to content

Commit 18b42fc

Browse files
committed
Added check to support a continuous run of a terminator to end a line
1 parent a9b7121 commit 18b42fc

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

cmd2/parsing.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -250,23 +250,18 @@ def parse(self, rawinput: str) -> Statement:
250250
tokens = self.tokenize(rawinput)
251251

252252
# of the valid terminators, find the first one to occur in the input
253-
terminator_pos = len(tokens)+1
254-
for test_terminator in self.terminators:
255-
try:
256-
pos = tokens.index(test_terminator)
257-
if pos < terminator_pos:
253+
terminator_pos = len(tokens) + 1
254+
for pos, cur_token in enumerate(tokens):
255+
for test_terminator in self.terminators:
256+
if cur_token.startswith(test_terminator):
258257
terminator_pos = pos
259258
terminator = test_terminator
260259
break
261-
except ValueError:
262-
# the terminator is not in the tokens
263-
pass
264260

265261
if terminator:
266262
if terminator == LINE_FEED:
267263
terminator_pos = len(tokens)+1
268-
else:
269-
terminator_pos = tokens.index(terminator)
264+
270265
# everything before the first terminator is the command and the args
271266
argv = tokens[:terminator_pos]
272267
(command, args) = self._command_and_args(argv)

0 commit comments

Comments
 (0)