Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libcmd.tex @ 27713:aade4bc125f8 legacy-trunk
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.
| author | Anthony Baxter <anthonybaxter@gmail.com> |
|---|---|
| date | Thu, 06 Feb 2003 01:45:11 +0000 |
| parents | 58a82a4be8b1 |
| children | 76376e5af388 |
line wrap: on
line diff
--- a/Doc/lib/libcmd.tex Wed Feb 05 23:13:00 2003 +0000 +++ b/Doc/lib/libcmd.tex Thu Feb 06 01:45:11 2003 +0000 @@ -11,17 +11,23 @@ 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}
