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