Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kmvanbrunt committed May 28, 2020
1 parent 6f91bea commit c30fcd3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/features/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
----------------------------
Expand Down
6 changes: 6 additions & 0 deletions docs/features/hooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------------
Expand Down

0 comments on commit c30fcd3

Please sign in to comment.