diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-05-16 00:22:43 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-05-16 00:22:43 -0400 |
commit | 18b42fcfbb9b071964bd9f8ba4c48b1767bc9327 (patch) | |
tree | 850cd8ec600964231f27343e0194368c3be5985e | |
parent | a9b712108e5af49937b0af3aa51db2ebe5c159e4 (diff) | |
download | cmd2-git-18b42fcfbb9b071964bd9f8ba4c48b1767bc9327.tar.gz |
Added check to support a continuous run of a terminator to end a line
-rw-r--r-- | cmd2/parsing.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/cmd2/parsing.py b/cmd2/parsing.py index ce15bd38..9fe8f6eb 100644 --- a/cmd2/parsing.py +++ b/cmd2/parsing.py @@ -250,23 +250,18 @@ class StatementParser: tokens = self.tokenize(rawinput) # of the valid terminators, find the first one to occur in the input - terminator_pos = len(tokens)+1 - for test_terminator in self.terminators: - try: - pos = tokens.index(test_terminator) - if pos < terminator_pos: + terminator_pos = len(tokens) + 1 + for pos, cur_token in enumerate(tokens): + for test_terminator in self.terminators: + if cur_token.startswith(test_terminator): terminator_pos = pos terminator = test_terminator break - except ValueError: - # the terminator is not in the tokens - pass if terminator: if terminator == LINE_FEED: terminator_pos = len(tokens)+1 - else: - terminator_pos = tokens.index(terminator) + # everything before the first terminator is the command and the args argv = tokens[:terminator_pos] (command, args) = self._command_and_args(argv) |