summaryrefslogtreecommitdiff
path: root/cmd2/parsing.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-08-09 00:25:57 -0400
committerGitHub <noreply@github.com>2018-08-09 00:25:57 -0400
commit88b739f6a11a2a1796b2758fa2ce94c562e24316 (patch)
tree13a9f8ab97ac1bf2d496ccd3bfd8cfe105064666 /cmd2/parsing.py
parent46955ec2f403a94ca3582fe3225bdcc369f334e1 (diff)
parent34784566f926b57234388150a550ca005f6f3ef9 (diff)
downloadcmd2-git-88b739f6a11a2a1796b2758fa2ce94c562e24316.tar.gz
Merge pull request #496 from python-cmd2/embedded_newlines
Fix #495 by allowing embedded newlines in unclosed quote marks when entering multiline commands
Diffstat (limited to 'cmd2/parsing.py')
-rw-r--r--cmd2/parsing.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/cmd2/parsing.py b/cmd2/parsing.py
index 475554b0..b67cef10 100644
--- a/cmd2/parsing.py
+++ b/cmd2/parsing.py
@@ -407,8 +407,8 @@ class StatementParser:
"""Partially parse input into a Statement object.
The command is identified, and shortcuts and aliases are expanded.
- Terminators, multiline commands, and output redirection are not
- parsed.
+ Multiline commands are identified, but terminators and output
+ redirection are not parsed.
This method is used by tab completion code and therefore must not
generate an exception if there are unclosed quotes.
@@ -420,8 +420,8 @@ class StatementParser:
- args
Different from parse(), this method does not remove redundant whitespace
- within statement.args. It does however, ensure args does not have leading
- or trailing whitespace.
+ within statement.args. It does however, ensure args does not have
+ leading or trailing whitespace.
"""
# expand shortcuts and aliases
line = self._expand(rawinput)
@@ -447,6 +447,12 @@ class StatementParser:
if not command or not args:
args = None
+ # set multiline
+ if command in self.multiline_commands:
+ multiline_command = command
+ else:
+ multiline_command = None
+
# build the statement
# string representation of args must be an empty string instead of
# None for compatibility with standard library cmd
@@ -454,6 +460,7 @@ class StatementParser:
raw=rawinput,
command=command,
args=args,
+ multiline_command=multiline_command,
)
return statement