MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / precmd

Method precmd

cmd2/cmd2.py:2824–2833  ·  view source on GitHub ↗

Ran just before the command is executed by [cmd2.Cmd.onecmd][] and after adding it to history (cmd Hook method). :param statement: subclass of str which also contains the parsed input :return: a potentially modified version of the input Statement object See [cmd2.Cmd.regist

(self, statement: Statement | str)

Source from the content-addressed store, hash-verified

2822 """
2823
2824 def precmd(self, statement: Statement | str) -> Statement:
2825 """Ran just before the command is executed by [cmd2.Cmd.onecmd][] and after adding it to history (cmd Hook method).
2826
2827 :param statement: subclass of str which also contains the parsed input
2828 :return: a potentially modified version of the input Statement object
2829
2830 See [cmd2.Cmd.register_postparsing_hook][] and [cmd2.Cmd.register_precmd_hook][] for more robust ways
2831 to run hooks before the command is executed. See [Hooks](../features/hooks.md) for more information.
2832 """
2833 return Statement(statement) if not isinstance(statement, Statement) else statement
2834
2835 def postcmd(self, stop: bool, statement: Statement | str) -> bool: # noqa: ARG002
2836 """Ran just after a command is executed by [cmd2.Cmd.onecmd][] (cmd inherited Hook method).

Callers 1

onecmd_plus_hooksMethod · 0.95

Calls 1

StatementClass · 0.85

Tested by

no test coverage detected