Skip to content

Commit c3f8160

Browse files
authored
Merge pull request #881 from python-cmd2/help_docs
Updated Sphinx docs about help
2 parents c0942f1 + 41e9ce2 commit c3f8160

File tree

1 file changed

+63
-11
lines changed

1 file changed

+63
-11
lines changed

docs/features/help.rst

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,60 @@
11
Help
22
====
33

4-
use the categorize() function to create help categories
4+
From our experience, end users rarely read documentation no matter how high-
5+
quality or useful that documentation might be. So it is important that you
6+
provide good built-in help within your application. Fortunately, ``cmd2``
7+
makes this easy.
58

6-
Use ``help_method()`` to custom roll your own help messages.
9+
Getting Help
10+
------------
711

8-
See :ref:`features/argument_processing:Help Messages`
12+
``cmd2`` makes it easy for end users of ``cmd2`` applications to get help via
13+
the built-in ``help`` command. The ``help`` command by itself displays a list
14+
of the commands available:
15+
16+
.. code-block:: text
17+
18+
(Cmd) help
19+
20+
Documented commands (use 'help -v' for verbose/'help <topic>' for details):
21+
===========================================================================
22+
alias help ipy py run_pyscript set shortcuts
23+
edit history macro quit run_script shell
24+
25+
The ``help`` command can also be used to provide detailed help for a specific
26+
command:
27+
28+
.. code-block:: text
29+
30+
(Cmd) help quit
31+
Usage: quit [-h]
32+
33+
Exit this application
34+
35+
optional arguments:
36+
-h, --help show this help message and exit
37+
38+
Providing Help
39+
--------------
40+
41+
``cmd2`` makes it easy for developers of ``cmd2`` applications to provide this
42+
help. By default, the help for a command is the docstring for the ``do_*``
43+
method defining the command - e.g. for a command **foo**, that command is
44+
implementd by defining the ``do_foo`` method and the docstring for that method
45+
is the help.
46+
47+
For commands which use one of the ``argparse`` decorators to parse arguments,
48+
help is provided by ``argparse``. See
49+
:ref:`features/argument_processing:Help Messages` for more information.
50+
51+
Occasionally there might be an unusual circumstance where providing static help
52+
text isn't good enough and you want to provide dynamic information in the help
53+
text for a command. To meet this need, if a ``help_foo`` method is defined to
54+
match the ``do_foo`` method, then that method will be used to provide the help
55+
for command **foo**. This dynamic help is only supported for commands which
56+
do not use an ``argparse`` decorator because didn't want different output for
57+
``help cmd`` than for ``cmd -h``.
958

1059
Categorizing Commands
1160
---------------------
@@ -124,18 +173,21 @@ The ``help`` command also has a verbose option (``help -v`` or ``help
124173

125174
Other
126175
================================================================================
127-
alias Define or display aliases
176+
alias Manage aliases
128177
config Config command
129-
edit Edit a file in a text editor
130-
help List available commands with "help" or detailed help with "help cmd"
131-
history usage: history [-h] [-r | -e | -s | -o FILE | -t TRANSCRIPT] [arg]
132-
py Invoke python command, shell, or script
178+
edit Run a text editor and optionally open a file with it
179+
help List available commands or provide detailed help for a specific command
180+
history View, run, edit, save, or clear previously entered commands
181+
macro Manage macros
182+
py Invoke Python command or shell
133183
quit Exits this application
134184
run_pyscript Runs a python script file inside the console
135185
run_script Runs commands in script file that is encoded as either ASCII or UTF-8 text
136-
set usage: set [-h] [-a] [-l] [settable [settable ...]]
186+
set Set a settable parameter or show current settings of parameters
137187
shell Execute a command as if at the OS prompt
138-
shortcuts Lists shortcuts available
139-
unalias Unsets aliases
188+
shortcuts List available shortcuts
140189
version Version command
141190

191+
When called with the ``-v`` flag for verbose help, the one-line description for
192+
each command is provided by the first line of the docstring for that command's
193+
associated ``do_*`` method.

0 commit comments

Comments
 (0)