annotate Doc/lib/libcmd.tex @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents 76376e5af388
children 60a708bf351a 284db2a5f620
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8918
acfffe14628e New section header style.
Fred Drake <fdrake@acm.org>
parents: 8716
diff changeset
1 \section{\module{cmd} ---
15142
563dee598d3a Fixed lots of small nits caught by Ka-Ping Yee <ping@lfw.org>.
Fred Drake <fdrake@acm.org>
parents: 13560
diff changeset
2 Support for line-oriented command interpreters}
563dee598d3a Fixed lots of small nits caught by Ka-Ping Yee <ping@lfw.org>.
Fred Drake <fdrake@acm.org>
parents: 13560
diff changeset
3
8716
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 8619
diff changeset
4 \declaremodule{standard}{cmd}
8918
acfffe14628e New section header style.
Fred Drake <fdrake@acm.org>
parents: 8716
diff changeset
5 \sectionauthor{Eric S. Raymond}{esr@snark.thyrsus.com}
15142
563dee598d3a Fixed lots of small nits caught by Ka-Ping Yee <ping@lfw.org>.
Fred Drake <fdrake@acm.org>
parents: 13560
diff changeset
6 \modulesynopsis{Build line-oriented command interpreters.}
8716
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 8619
diff changeset
7
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
9 The \class{Cmd} class provides a simple framework for writing
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 line-oriented command interpreters. These are often useful for
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 test harnesses, administrative tools, and prototypes that will
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 later be wrapped in a more sophisticated interface.
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
27713
aade4bc125f8 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
Anthony Baxter <anthonybaxter@gmail.com>
parents: 21548
diff changeset
14 \begin{classdesc}{Cmd}{\optional{completekey},\optional{stdin},\optional{stdout}}
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 A \class{Cmd} instance or subclass instance is a line-oriented
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
16 interpreter framework. There is no good reason to instantiate
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
17 \class{Cmd} itself; rather, it's useful as a superclass of an
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
18 interpreter class you define yourself in order to inherit
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
19 \class{Cmd}'s methods and encapsulate action methods.
18855
6f301b3cf323 Patch #416224: add readline completion to cmd.Cmd.
Martin v. Löwis <martin@v.loewis.de>
parents: 18488
diff changeset
20
27713
aade4bc125f8 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
Anthony Baxter <anthonybaxter@gmail.com>
parents: 21548
diff changeset
21 The optional argument \var{completekey} is the \refmodule{readline} name
aade4bc125f8 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
Anthony Baxter <anthonybaxter@gmail.com>
parents: 21548
diff changeset
22 of a completion key; it defaults to \kbd{Tab}. If \var{completekey} is
aade4bc125f8 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
Anthony Baxter <anthonybaxter@gmail.com>
parents: 21548
diff changeset
23 not \code{None} and \module{readline} is available, command completion
aade4bc125f8 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
Anthony Baxter <anthonybaxter@gmail.com>
parents: 21548
diff changeset
24 is done automatically.
aade4bc125f8 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
Anthony Baxter <anthonybaxter@gmail.com>
parents: 21548
diff changeset
25
aade4bc125f8 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
Anthony Baxter <anthonybaxter@gmail.com>
parents: 21548
diff changeset
26 The optional arguments \var{stdin} and \var{stdout} specify the
aade4bc125f8 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
Anthony Baxter <anthonybaxter@gmail.com>
parents: 21548
diff changeset
27 input and output file objects that the Cmd instance or subclass
aade4bc125f8 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
Anthony Baxter <anthonybaxter@gmail.com>
parents: 21548
diff changeset
28 instance will use for input and output. If not specified, they
aade4bc125f8 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
Anthony Baxter <anthonybaxter@gmail.com>
parents: 21548
diff changeset
29 will default to \var{sys.stdin} and \var{sys.stdout}.
aade4bc125f8 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
Anthony Baxter <anthonybaxter@gmail.com>
parents: 21548
diff changeset
30
27714
76376e5af388 Provide version changed info
Neal Norwitz <nnorwitz@gmail.com>
parents: 27713
diff changeset
31 \versionchanged[The \var{stdin} and \var{stdout} parameters were added.]{2.3}
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 \end{classdesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
33
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 \subsection{Cmd Objects}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 \label{Cmd-objects}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
36
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 A \class{Cmd} instance has the following methods:
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
38
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
39 \begin{methoddesc}{cmdloop}{\optional{intro}}
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 Repeatedly issue a prompt, accept input, parse an initial prefix off
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 the received input, and dispatch to action methods, passing them the
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 remainder of the line as argument.
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
43
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 The optional argument is a banner or intro string to be issued before the
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 first prompt (this overrides the \member{intro} class member).
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
46
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 If the \module{readline} module is loaded, input will automatically
18488
9977cf206532 Follow the recommended practices for keystroke representation; this
Fred Drake <fdrake@acm.org>
parents: 18244
diff changeset
48 inherit \program{bash}-like history-list editing (e.g. \kbd{Control-P}
9977cf206532 Follow the recommended practices for keystroke representation; this
Fred Drake <fdrake@acm.org>
parents: 18244
diff changeset
49 scrolls back to the last command, \kbd{Control-N} forward to the next
9977cf206532 Follow the recommended practices for keystroke representation; this
Fred Drake <fdrake@acm.org>
parents: 18244
diff changeset
50 one, \kbd{Control-F} moves the cursor to the right non-destructively,
9977cf206532 Follow the recommended practices for keystroke representation; this
Fred Drake <fdrake@acm.org>
parents: 18244
diff changeset
51 \kbd{Control-B} moves the cursor to the left non-destructively, etc.).
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
52
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
53 An end-of-file on input is passed back as the string \code{'EOF'}.
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
54
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
55 An interpreter instance will recognize a command name \samp{foo} if
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
56 and only if it has a method \method{do_foo()}. As a special case,
13560
6987e9450619 Resynchronize the TeX docs with (a) the module docstring, and (b) my recent
Eric S. Raymond <esr@thyrsus.com>
parents: 8918
diff changeset
57 a line beginning with the character \character{?} is dispatched to
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
58 the method \method{do_help()}. As another special case, a line
13560
6987e9450619 Resynchronize the TeX docs with (a) the module docstring, and (b) my recent
Eric S. Raymond <esr@thyrsus.com>
parents: 8918
diff changeset
59 beginning with the character \character{!} is dispatched to the
18860
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
60 method \method{do_shell()} (if such a method is defined).
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
61
18855
6f301b3cf323 Patch #416224: add readline completion to cmd.Cmd.
Martin v. Löwis <martin@v.loewis.de>
parents: 18488
diff changeset
62 If completion is enabled, completing commands will be done
6f301b3cf323 Patch #416224: add readline completion to cmd.Cmd.
Martin v. Löwis <martin@v.loewis.de>
parents: 18488
diff changeset
63 automatically, and completing of commands args is done by calling
18860
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
64 \method{complete_foo()} with arguments \var{text}, \var{line},
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
65 \var{begidx}, and \var{endidx}. \var{text} is the string prefix we
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
66 are attempting to match: all returned matches must begin with it.
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
67 \var{line} is the current input line with leading whitespace removed,
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
68 \var{begidx} and \var{endidx} are the beginning and ending indexes
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
69 of the prefix text, which could be used to provide different
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
70 completion depending upon which position the argument is in.
18855
6f301b3cf323 Patch #416224: add readline completion to cmd.Cmd.
Martin v. Löwis <martin@v.loewis.de>
parents: 18488
diff changeset
71
18860
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
72 All subclasses of \class{Cmd} inherit a predefined \method{do_help()}.
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
73 This method, called with an argument \code{'bar'}, invokes the
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
74 corresponding method \method{help_bar()}. With no argument,
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
75 \method{do_help()} lists all available help topics (that is, all
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
76 commands with corresponding \method{help_*()} methods), and also lists
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
77 any undocumented commands.
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 \end{methoddesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
79
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 \begin{methoddesc}{onecmd}{str}
21548
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
81 Interpret the argument as though it had been typed in response to the
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
82 prompt. This may be overridden, but should not normally need to be;
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
83 see the \method{precmd()} and \method{postcmd()} methods for useful
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
84 execution hooks. The return value is a flag indicating whether
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
85 interpretation of commands by the interpreter should stop.
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 \end{methoddesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
87
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 \begin{methoddesc}{emptyline}{}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 Method called when an empty line is entered in response to the prompt.
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 If this method is not overridden, it repeats the last nonempty command
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 entered.
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
92 \end{methoddesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
93
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 \begin{methoddesc}{default}{line}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
95 Method called on an input line when the command prefix is not
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 recognized. If this method is not overridden, it prints an
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
97 error message and returns.
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
98 \end{methoddesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
99
18855
6f301b3cf323 Patch #416224: add readline completion to cmd.Cmd.
Martin v. Löwis <martin@v.loewis.de>
parents: 18488
diff changeset
100 \begin{methoddesc}{completedefault}{text, line, begidx, endidx}
6f301b3cf323 Patch #416224: add readline completion to cmd.Cmd.
Martin v. Löwis <martin@v.loewis.de>
parents: 18488
diff changeset
101 Method called to complete an input line when no command-specific
18860
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
102 \method{complete_*()} method is available. By default, it returns an
18855
6f301b3cf323 Patch #416224: add readline completion to cmd.Cmd.
Martin v. Löwis <martin@v.loewis.de>
parents: 18488
diff changeset
103 empty list.
6f301b3cf323 Patch #416224: add readline completion to cmd.Cmd.
Martin v. Löwis <martin@v.loewis.de>
parents: 18488
diff changeset
104 \end{methoddesc}
6f301b3cf323 Patch #416224: add readline completion to cmd.Cmd.
Martin v. Löwis <martin@v.loewis.de>
parents: 18488
diff changeset
105
21548
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
106 \begin{methoddesc}{precmd}{line}
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
107 Hook method executed just before the command line \var{line} is
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
108 interpreted, but after the input prompt is generated and issued. This
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
109 method is a stub in \class{Cmd}; it exists to be overridden by
21548
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
110 subclasses. The return value is used as the command which will be
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
111 executed by the \method{onecmd()} method; the \method{precmd()}
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
112 implementation may re-write the command or simply return \var{line}
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
113 unchanged.
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
114 \end{methoddesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
115
21548
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
116 \begin{methoddesc}{postcmd}{stop, line}
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
117 Hook method executed just after a command dispatch is finished. This
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 method is a stub in \class{Cmd}; it exists to be overridden by
21548
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
119 subclasses. \var{line} is the command line which was executed, and
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
120 \var{stop} is a flag which indicates whether execution will be
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
121 terminated after the call to \method{postcmd()}; this will be the
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
122 return value of the \method{onecmd()} method. The return value of
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
123 this method will be used as the new value for the internal flag which
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
124 corresponds to \var{stop}; returning false will cause interpretation
58a82a4be8b1 Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
Fred Drake <fdrake@acm.org>
parents: 18860
diff changeset
125 to continue.
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
126 \end{methoddesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
127
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
128 \begin{methoddesc}{preloop}{}
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
129 Hook method executed once when \method{cmdloop()} is called. This
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
130 method is a stub in \class{Cmd}; it exists to be overridden by
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
131 subclasses.
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
132 \end{methoddesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
133
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
134 \begin{methoddesc}{postloop}{}
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
135 Hook method executed once when \method{cmdloop()} is about to return.
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
136 This method is a stub in \class{Cmd}; it exists to be overridden by
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
137 subclasses.
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
138 \end{methoddesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
139
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
140 Instances of \class{Cmd} subclasses have some public instance variables:
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
141
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
142 \begin{memberdesc}{prompt}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
143 The prompt issued to solicit input.
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
144 \end{memberdesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
145
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
146 \begin{memberdesc}{identchars}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
147 The string of characters accepted for the command prefix.
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
148 \end{memberdesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
149
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
150 \begin{memberdesc}{lastcmd}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
151 The last nonempty command prefix seen.
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
152 \end{memberdesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
153
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
154 \begin{memberdesc}{intro}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
155 A string to issue as an intro or banner. May be overridden by giving
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
156 the \method{cmdloop()} method an argument.
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
157 \end{memberdesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
158
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
159 \begin{memberdesc}{doc_header}
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
160 The header to issue if the help output has a section for documented
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
161 commands.
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
162 \end{memberdesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
163
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 \begin{memberdesc}{misc_header}
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
165 The header to issue if the help output has a section for miscellaneous
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
166 help topics (that is, there are \method{help_*()} methods without
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
167 corresponding \method{do_*()} methods).
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
168 \end{memberdesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
169
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
170 \begin{memberdesc}{undoc_header}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
171 The header to issue if the help output has a section for undocumented
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
172 commands (that is, there are \method{do_*()} methods without
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
173 corresponding \method{help_*()} methods).
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
174 \end{memberdesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
175
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
176 \begin{memberdesc}{ruler}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
177 The character used to draw separator lines under the help-message
8619
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
178 headers. If empty, no ruler line is drawn. It defaults to
6ed503d9c3d5 Normalize the markup.
Fred Drake <fdrake@acm.org>
parents: 8572
diff changeset
179 \character{=}.
8572
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
180 \end{memberdesc}
ea8f0f5ab015 Contributions by Eric Raymond: documentation for modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
181
17218
b3dce06868d6 Document use_rawinput. (Although now that I think more about it, a
Guido van Rossum <guido@python.org>
parents: 15142
diff changeset
182 \begin{memberdesc}{use_rawinput}
b3dce06868d6 Document use_rawinput. (Although now that I think more about it, a
Guido van Rossum <guido@python.org>
parents: 15142
diff changeset
183 A flag, defaulting to true. If true, \method{cmdloop()} uses
b3dce06868d6 Document use_rawinput. (Although now that I think more about it, a
Guido van Rossum <guido@python.org>
parents: 15142
diff changeset
184 \function{raw_input()} to display a prompt and read the next command;
18860
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
185 if false, \method{sys.stdout.write()} and
ae19c6990749 Make some adjustments to the markup, and fix up some style-guide issues.
Fred Drake <fdrake@acm.org>
parents: 18855
diff changeset
186 \method{sys.stdin.readline()} are used. (This means that by
18244
24c29b371510 Correct erroneous description of precmd.
Eric S. Raymond <esr@thyrsus.com>
parents: 17218
diff changeset
187 importing \module{readline}, on systems that support it, the
24c29b371510 Correct erroneous description of precmd.
Eric S. Raymond <esr@thyrsus.com>
parents: 17218
diff changeset
188 interpreter will automatically support Emacs-like line editing
24c29b371510 Correct erroneous description of precmd.
Eric S. Raymond <esr@thyrsus.com>
parents: 17218
diff changeset
189 and command-history keystrokes.)
17218
b3dce06868d6 Document use_rawinput. (Although now that I think more about it, a
Guido van Rossum <guido@python.org>
parents: 15142
diff changeset
190 \end{memberdesc}