Skip to content

Commit c30fcd3

Browse files
committed
Updated docs
1 parent 6f91bea commit c30fcd3

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

docs/features/commands.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ it should stop prompting for user input and cleanly exit. ``cmd2`` already
129129
includes a ``quit`` command, but if you wanted to make another one called
130130
``finis`` you could::
131131

132-
def do_finis(self, line):
132+
def do_finish(self, line):
133133
"""Exit the application"""
134134
return True
135135

@@ -186,6 +186,19 @@ catch it and display it for you. The `debug` :ref:`setting
186186
name and message. If `debug` is `true`, ``cmd2`` will display a traceback, and
187187
then display the exception name and message.
188188

189+
There are a few exceptions which commands can raise that do not print as
190+
described above:
191+
192+
- :attr:`cmd2.exceptions.SkipPostcommandHooks` - all postcommand hooks are
193+
skipped and no exception prints
194+
- :attr:`cmd2.exceptions.Cmd2ArgparseError` - behaves like
195+
``SkipPostcommandHooks``
196+
- ``SystemExit`` - ``stop`` will be set to ``True`` in an attempt to stop the
197+
command loop
198+
- ``KeyboardInterrupt`` - raised if running in a text script and ``stop`` isn't
199+
already True to stop the script
200+
201+
All other ``BaseExceptions`` are not caught by ``cmd2`` and will be raised
189202

190203
Disabling or Hiding Commands
191204
----------------------------

docs/features/hooks.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ blindly returns ``False``, a prior hook's requst to exit the application will
291291
not be honored. It's best to return the value you were passed unless you have a
292292
compelling reason to do otherwise.
293293

294+
To purposefully and silently skip postcommand hooks, commands can raise any of
295+
of the following exceptions.
296+
297+
- :attr:`cmd2.exceptions.SkipPostcommandHooks`
298+
- :attr:`cmd2.exceptions.Cmd2ArgparseError`
299+
294300

295301
Command Finalization Hooks
296302
--------------------------

0 commit comments

Comments
 (0)