diff options
-rw-r--r-- | cmd2/parsing.py | 4 | ||||
-rw-r--r-- | tests/test_parsing.py | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/cmd2/parsing.py b/cmd2/parsing.py index 90484d76..2f22b607 100644 --- a/cmd2/parsing.py +++ b/cmd2/parsing.py @@ -193,12 +193,14 @@ class Statement(str): rtn = self.command_and_args if self.multiline_command: rtn += constants.MULTILINE_TERMINATOR + elif self.terminator: + rtn += self.terminator if self.suffix: rtn += ' ' + self.suffix if self.pipe_to: - rtn += ' | ' + self.pipe_to + rtn += ' | ' + ' '.join(self.pipe_to) if self.output: rtn += ' ' + self.output diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 78adf880..c341f9e3 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -10,8 +10,10 @@ import attr import pytest import cmd2 -from cmd2.parsing import StatementParser from cmd2 import utils +from cmd2.constants import MULTILINE_TERMINATOR +from cmd2.parsing import StatementParser + @pytest.fixture def parser(): @@ -147,6 +149,7 @@ def test_parse_word_plus_terminator(parser, line, terminator): assert statement.argv == ['termbare'] assert not statement.arg_list assert statement.terminator == terminator + assert statement.expanded_command_line == statement.command + statement.terminator @pytest.mark.parametrize('line,terminator', [ ('termbare; suffx', ';'), @@ -163,6 +166,7 @@ def test_parse_suffix_after_terminator(parser, line, terminator): assert not statement.arg_list assert statement.terminator == terminator assert statement.suffix == 'suffx' + assert statement.expanded_command_line == statement.command + statement.terminator + ' ' + statement.suffix def test_parse_command_with_args(parser): line = 'command with args' @@ -258,6 +262,7 @@ def test_parse_simple_pipe(parser, line): assert statement.argv == ['simple'] assert not statement.arg_list assert statement.pipe_to == ['piped'] + assert statement.expanded_command_line == statement.command + ' | ' + ' '.join(statement.pipe_to) def test_parse_double_pipe_is_not_a_pipe(parser): line = 'double-pipe || is not a pipe' @@ -294,6 +299,7 @@ def test_parse_redirect(parser,line, output): assert statement.args == statement assert statement.output == output assert statement.output_to == 'out.txt' + assert statement.expanded_command_line == statement.command + ' ' + statement.output + ' ' + statement.output_to def test_parse_redirect_with_args(parser): line = 'output into > afile.txt' @@ -539,6 +545,7 @@ def test_parse_alias_on_multiline_command(parser): assert statement.args == statement assert statement == 'has > inside an unfinished command' assert statement.terminator == '' + assert statement.expanded_command_line == statement.multiline_command + ' ' + statement + MULTILINE_TERMINATOR @pytest.mark.parametrize('line,output', [ ('helpalias > out.txt', '>'), |