Check if the given line is a complete statement. :param line: the current input string to check :return: the completed Statement :raises Cmd2ShlexError: if a shlex error occurs on a non-multiline command :raises IncompleteStatement: if more input is needed for multil
(self, line: str)
| 3053 | return False |
| 3054 | |
| 3055 | def _check_statement_complete(self, line: str) -> Statement: |
| 3056 | """Check if the given line is a complete statement. |
| 3057 | |
| 3058 | :param line: the current input string to check |
| 3059 | :return: the completed Statement |
| 3060 | :raises Cmd2ShlexError: if a shlex error occurs on a non-multiline command |
| 3061 | :raises IncompleteStatement: if more input is needed for multiline |
| 3062 | :raises EmptyStatement: if the command is blank |
| 3063 | """ |
| 3064 | try: |
| 3065 | statement = self.statement_parser.parse(line) |
| 3066 | |
| 3067 | # Check if we have a finished multiline command or a standard command |
| 3068 | if (statement.multiline_command and statement.terminator) or not statement.multiline_command: |
| 3069 | if not statement.command: |
| 3070 | raise EmptyStatement |
| 3071 | return statement |
| 3072 | |
| 3073 | except Cmd2ShlexError: |
| 3074 | # Check if the error is occurring within a multiline command |
| 3075 | partial_statement = self.statement_parser.parse_command_only(line) |
| 3076 | if not partial_statement.multiline_command: |
| 3077 | # It's a standard command with a quoting error, raise it |
| 3078 | raise |
| 3079 | |
| 3080 | # If we reached here, the statement is incomplete: |
| 3081 | # - Multiline command missing a terminator |
| 3082 | # - Multiline command with an unclosed quotation mark |
| 3083 | raise IncompleteStatement |
| 3084 | |
| 3085 | def _complete_statement(self, line: str) -> Statement: |
| 3086 | """Keep accepting lines of input until the command is complete. |
no test coverage detected