Keep accepting lines of input until the command is complete. :param line: the line being parsed :return: the completed Statement :raises Cmd2ShlexError: if a shlex error occurs (e.g. No closing quotation) :raises EmptyStatement: when the resulting Statement is blank
(self, line: str)
| 3083 | raise IncompleteStatement |
| 3084 | |
| 3085 | def _complete_statement(self, line: str) -> Statement: |
| 3086 | """Keep accepting lines of input until the command is complete. |
| 3087 | |
| 3088 | :param line: the line being parsed |
| 3089 | :return: the completed Statement |
| 3090 | :raises Cmd2ShlexError: if a shlex error occurs (e.g. No closing quotation) |
| 3091 | :raises EmptyStatement: when the resulting Statement is blank |
| 3092 | """ |
| 3093 | while True: |
| 3094 | try: |
| 3095 | return self._check_statement_complete(line) |
| 3096 | except IncompleteStatement: # noqa: PERF203 |
| 3097 | # If incomplete, we need to fetch the next line |
| 3098 | try: |
| 3099 | try: |
| 3100 | nextline = self._read_command_line(self.continuation_prompt) |
| 3101 | except EOFError: |
| 3102 | # Add a blank line, which serves as a command terminator. |
| 3103 | nextline = "\n" |
| 3104 | self.poutput(nextline) |
| 3105 | |
| 3106 | line += f"\n{nextline}" |
| 3107 | |
| 3108 | except KeyboardInterrupt: |
| 3109 | self.poutput("^C") |
| 3110 | raise EmptyStatement from None |
| 3111 | |
| 3112 | def _input_line_to_statement(self, line: str) -> Statement: |
| 3113 | """Parse the user's input line and convert it to a Statement, ensuring that all macros are also resolved. |