From f616d78ba70b6f48a2c94a66d4657f4e214b3155 Mon Sep 17 00:00:00 2001 From: kotfu Date: Sun, 27 May 2018 21:35:34 -0600 Subject: Differentiate between postparsing hooks and precommand hooks --- docs/hooks.rst | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/hooks.rst b/docs/hooks.rst index 7141c729..b07f1e94 100644 --- a/docs/hooks.rst +++ b/docs/hooks.rst @@ -163,6 +163,10 @@ If a postparsing hook returns ``True`` as the first value in the tuple: Precommand Hooks ^^^^^^^^^^^^^^^^^ +A precommand hook is defined in ``cmd.Cmd``. It is not able to request that the +app terminate, but it is passed the user input and allowed to make changes. If +your hook needs to be able to exit the application, you should implement it as a postparsing hook. + Once output is redirected and the timer started, all the hooks registered with ``register_precmd_hook()`` are called. Here's how you do it:: -- cgit v1.2.1