diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-05-28 12:47:56 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-05-28 12:47:56 -0400 |
commit | c30fcd3d764b3b7a6f112c49ed5393650f4f9bcb (patch) | |
tree | 97fbe7373f1edd40e006e0d68b1a464a1ec5afdd /docs | |
parent | 6f91bea16a00f48ff6be729ed12a5920ebac3baa (diff) | |
download | cmd2-git-c30fcd3d764b3b7a6f112c49ed5393650f4f9bcb.tar.gz |
Updated docs
Diffstat (limited to 'docs')
-rw-r--r-- | docs/features/commands.rst | 15 | ||||
-rw-r--r-- | docs/features/hooks.rst | 6 |
2 files changed, 20 insertions, 1 deletions
diff --git a/docs/features/commands.rst b/docs/features/commands.rst index 823c3ca6..13a4ac1f 100644 --- a/docs/features/commands.rst +++ b/docs/features/commands.rst @@ -129,7 +129,7 @@ it should stop prompting for user input and cleanly exit. ``cmd2`` already includes a ``quit`` command, but if you wanted to make another one called ``finis`` you could:: - def do_finis(self, line): + def do_finish(self, line): """Exit the application""" return True @@ -186,6 +186,19 @@ catch it and display it for you. The `debug` :ref:`setting name and message. If `debug` is `true`, ``cmd2`` will display a traceback, and then display the exception name and message. +There are a few exceptions which commands can raise that do not print as +described above: + +- :attr:`cmd2.exceptions.SkipPostcommandHooks` - all postcommand hooks are + skipped and no exception prints +- :attr:`cmd2.exceptions.Cmd2ArgparseError` - behaves like + ``SkipPostcommandHooks`` +- ``SystemExit`` - ``stop`` will be set to ``True`` in an attempt to stop the + command loop +- ``KeyboardInterrupt`` - raised if running in a text script and ``stop`` isn't + already True to stop the script + +All other ``BaseExceptions`` are not caught by ``cmd2`` and will be raised Disabling or Hiding Commands ---------------------------- diff --git a/docs/features/hooks.rst b/docs/features/hooks.rst index fec8e258..4c615586 100644 --- a/docs/features/hooks.rst +++ b/docs/features/hooks.rst @@ -291,6 +291,12 @@ blindly returns ``False``, a prior hook's requst to exit the application will not be honored. It's best to return the value you were passed unless you have a compelling reason to do otherwise. +To purposefully and silently skip postcommand hooks, commands can raise any of +of the following exceptions. + +- :attr:`cmd2.exceptions.SkipPostcommandHooks` +- :attr:`cmd2.exceptions.Cmd2ArgparseError` + Command Finalization Hooks -------------------------- |