Accept unique abbreviated commands.
(self, data: cmd2.plugin.PostparsingData)
| 78 | return data |
| 79 | |
| 80 | def abbrev_hook(self, data: cmd2.plugin.PostparsingData) -> cmd2.plugin.PostparsingData: |
| 81 | """Accept unique abbreviated commands.""" |
| 82 | func = self.get_command_func(data.statement.command) |
| 83 | if func is None: |
| 84 | # check if the entered command might be an abbreviation |
| 85 | possible_cmds = [cmd for cmd in self.get_all_commands() if cmd.startswith(data.statement.command)] |
| 86 | if len(possible_cmds) == 1: |
| 87 | raw = data.statement.raw.replace(data.statement.command, possible_cmds[0], 1) |
| 88 | data.statement = self.statement_parser.parse(raw) |
| 89 | return data |
| 90 | |
| 91 | def proof_hook(self, data: cmd2.plugin.PostcommandData) -> cmd2.plugin.PostcommandData: |
| 92 | """Update the shell prompt with the new raw statement after postparsing hooks are finished.""" |
nothing calls this directly
no test coverage detected