diff options
| author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-02-06 21:40:00 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-06 21:40:00 -0500 |
| commit | bc9fd93cf00dc8adddb87b1fd973309d6c38c2a5 (patch) | |
| tree | fc8ff817e8d21809a14672588fc2cf5c7cded531 /docs/hooks.rst | |
| parent | 911d9651dd5370f4432b45ba1e481309d01178d5 (diff) | |
| parent | ec404a6451a608ae6fcc34420b7abf8ae436d464 (diff) | |
| download | cmd2-git-0.9.8.tar.gz | |
Merge pull request #624 from python-cmd2/doc_updates0.9.8
Minor doc updates that fix a few typos and inaccuracies
Diffstat (limited to 'docs/hooks.rst')
| -rw-r--r-- | docs/hooks.rst | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/docs/hooks.rst b/docs/hooks.rst index 1696d365..35753e59 100644 --- a/docs/hooks.rst +++ b/docs/hooks.rst @@ -239,7 +239,7 @@ Here's how to define and register a postcommand hook:: self.register_postcmd_hook(self.myhookmethod) def myhookmethod(self, data: cmd2.plugin.PostcommandData) -> cmd2.plugin.PostcommandData: - return stop + return data Your hook will be passed a ``PostcommandData`` object, which has a ``statement`` attribute that describes the command which was executed. If your postcommand @@ -254,10 +254,11 @@ After all registered postcommand hooks have been called, ``self.postcmd(statement)`` will be called to retain full backward compatibility with ``cmd.Cmd``. -If any postcommand hook (registered or ``self.postcmd()``) returns ``True``, -subsequent postcommand hooks will still be called, as will the command -finalization hooks, but once those hooks have all been called, the application -will terminate. +If any postcommand hook (registered or ``self.postcmd()``) returns a ``PostcommandData`` object +with the stop attribute set to ``True``, subsequent postcommand hooks will still be called, as +will the command finalization hooks, but once those hooks have all been called, the application +will terminate. Likewise, if ``self.postcmd()`` returns ``True``, the command finalization hooks +will be called before the application terminates. Any postcommand hook can change the value of the ``stop`` parameter before returning it, and the modified value will be passed to the next postcommand |
