@@ -76,27 +76,30 @@ A :class:`Cmd` instance has the following methods:
76
76
single: ! (exclamation); in a command interpreter
77
77
78
78
An interpreter instance will recognize a command name ``foo `` if and only if it
79
- has a method :meth: `do_foo `. As a special case, a line beginning with the
79
+ has a method :meth: `! do_foo `. As a special case, a line beginning with the
80
80
character ``'?' `` is dispatched to the method :meth: `do_help `. As another
81
81
special case, a line beginning with the character ``'!' `` is dispatched to the
82
- method :meth: `do_shell ` (if such a method is defined).
82
+ method :meth: `! do_shell ` (if such a method is defined).
83
83
84
84
This method will return when the :meth: `postcmd ` method returns a true value.
85
85
The *stop * argument to :meth: `postcmd ` is the return value from the command's
86
86
corresponding :meth: `!do_\* ` method.
87
87
88
88
If completion is enabled, completing commands will be done automatically, and
89
- completing of commands args is done by calling :meth: `complete_foo ` with
89
+ completing of commands args is done by calling :meth: `! complete_foo ` with
90
90
arguments *text *, *line *, *begidx *, and *endidx *. *text * is the string prefix
91
91
we are attempting to match: all returned matches must begin with it. *line * is
92
92
the current input line with leading whitespace removed, *begidx * and *endidx *
93
93
are the beginning and ending indexes of the prefix text, which could be used to
94
94
provide different completion depending upon which position the argument is in.
95
95
96
- All subclasses of :class: `Cmd ` inherit a predefined :meth: `do_help `. This
96
+
97
+ .. method :: Cmd.do_help(arg)
98
+
99
+ All subclasses of :class: `Cmd ` inherit a predefined :meth: `!do_help `. This
97
100
method, called with an argument ``'bar' ``, invokes the corresponding method
98
- :meth: `help_bar `, and if that is not present, prints the docstring of
99
- :meth: `do_bar `, if available. With no argument, :meth: `do_help ` lists all
101
+ :meth: `! help_bar `, and if that is not present, prints the docstring of
102
+ :meth: `! do_bar `, if available. With no argument, :meth: `! do_help ` lists all
100
103
available help topics (that is, all commands with corresponding
101
104
:meth: `!help_\* ` methods or commands that have docstrings), and also lists any
102
105
undocumented commands.
@@ -229,8 +232,8 @@ Instances of :class:`Cmd` subclasses have some public instance variables:
229
232
.. attribute :: Cmd.use_rawinput
230
233
231
234
A flag, defaulting to true. If true, :meth: `cmdloop ` uses :func: `input ` to
232
- display a prompt and read the next command; if false, :meth : `sys.stdout.write `
233
- and :meth : `sys.stdin.readline ` are used. (This means that by importing
235
+ display a prompt and read the next command; if false, :data : `sys.stdout.write() <sys.stdout> `
236
+ and :data : `sys.stdin.readline() <sys.stdin> ` are used. (This means that by importing
234
237
:mod: `readline `, on systems that support it, the interpreter will automatically
235
238
support :program: `Emacs `\ -like line editing and command-history keystrokes.)
236
239
@@ -249,14 +252,14 @@ This section presents a simple example of how to build a shell around a few of
249
252
the commands in the :mod: `turtle ` module.
250
253
251
254
Basic turtle commands such as :meth: `~turtle.forward ` are added to a
252
- :class: `Cmd ` subclass with method named :meth: `do_forward `. The argument is
255
+ :class: `Cmd ` subclass with method named :meth: `! do_forward `. The argument is
253
256
converted to a number and dispatched to the turtle module. The docstring is
254
257
used in the help utility provided by the shell.
255
258
256
259
The example also includes a basic record and playback facility implemented with
257
260
the :meth: `~Cmd.precmd ` method which is responsible for converting the input to
258
- lowercase and writing the commands to a file. The :meth: `do_playback ` method
259
- reads the file and adds the recorded commands to the :attr: `cmdqueue ` for
261
+ lowercase and writing the commands to a file. The :meth: `! do_playback ` method
262
+ reads the file and adds the recorded commands to the :attr: `~Cmd. cmdqueue ` for
260
263
immediate playback::
261
264
262
265
import cmd, sys
0 commit comments