mirror of
https://github.com/python/cpython.git
synced 2025-11-13 07:26:31 +00:00
Elaborate the descriptions for onecmd(), precmd(), and postcmd() so they are
useful.
This commit is contained in:
parent
fd7f115a0e
commit
7c9a53dfc0
1 changed files with 20 additions and 9 deletions
|
|
@ -22,7 +22,6 @@ The optional argument is the \refmodule{readline} name of a completion
|
||||||
key; it defaults to \kbd{Tab}. If \var{completekey} is not \code{None}
|
key; it defaults to \kbd{Tab}. If \var{completekey} is not \code{None}
|
||||||
and \module{readline} is available, command completion is done
|
and \module{readline} is available, command completion is done
|
||||||
automatically.
|
automatically.
|
||||||
|
|
||||||
\end{classdesc}
|
\end{classdesc}
|
||||||
|
|
||||||
\subsection{Cmd Objects}
|
\subsection{Cmd Objects}
|
||||||
|
|
@ -72,8 +71,11 @@ any undocumented commands.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{onecmd}{str}
|
\begin{methoddesc}{onecmd}{str}
|
||||||
Interpret the argument as though it had been typed in in
|
Interpret the argument as though it had been typed in response to the
|
||||||
response to the prompt.
|
prompt. This may be overridden, but should not normally need to be;
|
||||||
|
see the \method{precmd()} and \method{postcmd()} methods for useful
|
||||||
|
execution hooks. The return value is a flag indicating whether
|
||||||
|
interpretation of commands by the interpreter should stop.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{emptyline}{}
|
\begin{methoddesc}{emptyline}{}
|
||||||
|
|
@ -94,17 +96,26 @@ Method called to complete an input line when no command-specific
|
||||||
empty list.
|
empty list.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{precmd}{}
|
\begin{methoddesc}{precmd}{line}
|
||||||
Hook method executed just before the command line is interpreted, but
|
Hook method executed just before the command line \var{line} is
|
||||||
after the input prompt is generated and issued. This
|
interpreted, but after the input prompt is generated and issued. This
|
||||||
method is a stub in \class{Cmd}; it exists to be overridden by
|
method is a stub in \class{Cmd}; it exists to be overridden by
|
||||||
subclasses.
|
subclasses. The return value is used as the command which will be
|
||||||
|
executed by the \method{onecmd()} method; the \method{precmd()}
|
||||||
|
implementation may re-write the command or simply return \var{line}
|
||||||
|
unchanged.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{postcmd}{}
|
\begin{methoddesc}{postcmd}{stop, line}
|
||||||
Hook method executed just after a command dispatch is finished. This
|
Hook method executed just after a command dispatch is finished. This
|
||||||
method is a stub in \class{Cmd}; it exists to be overridden by
|
method is a stub in \class{Cmd}; it exists to be overridden by
|
||||||
subclasses.
|
subclasses. \var{line} is the command line which was executed, and
|
||||||
|
\var{stop} is a flag which indicates whether execution will be
|
||||||
|
terminated after the call to \method{postcmd()}; this will be the
|
||||||
|
return value of the \method{onecmd()} method. The return value of
|
||||||
|
this method will be used as the new value for the internal flag which
|
||||||
|
corresponds to \var{stop}; returning false will cause interpretation
|
||||||
|
to continue.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{preloop}{}
|
\begin{methoddesc}{preloop}{}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue