summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorAnthony Baxter <anthonybaxter@gmail.com>2003-02-06 01:45:11 (GMT)
committerAnthony Baxter <anthonybaxter@gmail.com>2003-02-06 01:45:11 (GMT)
commit983b00882400986b292837a25ef866fc897d603b (patch)
tree57dc9d3b234310806dca8ae5a892ca5f55ad7883 /Doc
parent985eba53f5d1ac45037fbf19b6955c74823c1ded (diff)
downloadcpython-983b00882400986b292837a25ef866fc897d603b.zip
cpython-983b00882400986b292837a25ef866fc897d603b.tar.gz
cpython-983b00882400986b292837a25ef866fc897d603b.tar.bz2
Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
This patch adds stdin, stdout as optional arguments to the cmd.Cmd constructor (defaulting to sys.stdin, sys.stdout), and changes the Cmd methods throughout to use self.stdout.write() and self.stdin.foo for output and input. This allows much greater flexibility for using cmd - for instance, hooking it into a telnet server. Patch for library module and for documentation.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libcmd.tex16
1 files changed, 11 insertions, 5 deletions
diff --git a/Doc/lib/libcmd.tex b/Doc/lib/libcmd.tex
index 59d573f..4b2af91 100644
--- a/Doc/lib/libcmd.tex
+++ b/Doc/lib/libcmd.tex
@@ -11,17 +11,23 @@ line-oriented command interpreters. These are often useful for
test harnesses, administrative tools, and prototypes that will
later be wrapped in a more sophisticated interface.
-\begin{classdesc}{Cmd}{\optional{completekey}}
+\begin{classdesc}{Cmd}{\optional{completekey},\optional{stdin},\optional{stdout}}
A \class{Cmd} instance or subclass instance is a line-oriented
interpreter framework. There is no good reason to instantiate
\class{Cmd} itself; rather, it's useful as a superclass of an
interpreter class you define yourself in order to inherit
\class{Cmd}'s methods and encapsulate action methods.
-The optional argument is the \refmodule{readline} name of a completion
-key; it defaults to \kbd{Tab}. If \var{completekey} is not \code{None}
-and \module{readline} is available, command completion is done
-automatically.
+The optional argument \var{completekey} is the \refmodule{readline} name
+of a completion key; it defaults to \kbd{Tab}. If \var{completekey} is
+not \code{None} and \module{readline} is available, command completion
+is done automatically.
+
+The optional arguments \var{stdin} and \var{stdout} specify the
+input and output file objects that the Cmd instance or subclass
+instance will use for input and output. If not specified, they
+will default to \var{sys.stdin} and \var{sys.stdout}.
+
\end{classdesc}
\subsection{Cmd Objects}