summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-04-23 22:55:24 -0600
committerkotfu <kotfu@kotfu.net>2018-04-23 22:55:24 -0600
commit3441d1e5abcd95ff9100905a9184400d590c600d (patch)
tree37481ca9122980155f062af96f23a7343137ce12
parentc378b1da3c1533f538ae616e550dd4ffd270d85f (diff)
downloadcmd2-git-3441d1e5abcd95ff9100905a9184400d590c600d.tar.gz
Multiline now working
-rwxr-xr-xcmd2/cmd2.py4
-rw-r--r--cmd2/parsing.py4
-rw-r--r--tests/test_shlexparsing.py8
3 files changed, 6 insertions, 10 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index b4c1dbf6..7b01a653 100755
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -2198,7 +2198,7 @@ class Cmd(cmd.Cmd):
# terminator
newline = '\n'
self.poutput(newline)
- line = '{}\n{}\n'.format(statement.raw, newline)
+ line = '{}\n{}'.format(statement.raw, newline)
except KeyboardInterrupt:
self.poutput('^C')
statement = self.command_parser.parseString('')
@@ -2212,7 +2212,7 @@ class Cmd(cmd.Cmd):
# terminator
newline = '\n'
self.poutput(newline)
- line = '{}\n{}\n'.format(statement.raw, newline)
+ line = '{}\n{}'.format(statement.raw, newline)
statement = self.command_parser.parseString(line)
if not statement.command:
diff --git a/cmd2/parsing.py b/cmd2/parsing.py
index 2c01fb70..ffeb8bbe 100644
--- a/cmd2/parsing.py
+++ b/cmd2/parsing.py
@@ -7,7 +7,7 @@ import shlex
import cmd2
-BLANK_LINE = '\n\n'
+BLANK_LINE = '\n'
class Statement(str):
"""String subclass with additional attributes to store the results of parsing.
@@ -91,7 +91,7 @@ class CommandParser():
# we have to do this before we shlex on whitespace because it
# destroys all unquoted whitespace in the input
terminator = None
- if line[-2:] == BLANK_LINE:
+ if line[-1:] == BLANK_LINE:
terminator = BLANK_LINE
s = shlex.shlex(line, posix=False)
diff --git a/tests/test_shlexparsing.py b/tests/test_shlexparsing.py
index 269a5753..936e6092 100644
--- a/tests/test_shlexparsing.py
+++ b/tests/test_shlexparsing.py
@@ -249,18 +249,14 @@ def test_parse_multiline_termninated_by_empty_line(parser):
results = parser.parseString(line)
assert results.multilineCommand == 'multiline'
assert results.args == 'command ends'
- assert len(results.terminator) == 2
- assert results.terminator[0] == '\n'
- assert results.terminator[1] == '\n'
+ assert results.terminator == '\n'
def test_parse_multiline_ignores_terminators_in_comments(parser):
line = 'multiline command "with term; ends" now\n\n'
results = parser.parseString(line)
assert results.multilineCommand == 'multiline'
assert results.args == 'command "with term; ends" now'
- assert len(results.terminator) == 2
- assert results.terminator[0] == '\n'
- assert results.terminator[1] == '\n'
+ assert results.terminator == '\n'
def test_parse_command_with_unicode_args(parser):
line = 'drink café'