Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Doc/library/cmd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ A :class:`Cmd` instance has the following methods:
cursor to the left non-destructively, etc.).

An end-of-file on input is passed back as the string ``'EOF'``.
To handle this gracefully, define a :meth:`!do_EOF` method in your subclass
(see :ref:`cmd-example` below).

.. index::
single: ? (question mark); in a command interpreter
Expand Down Expand Up @@ -117,7 +119,8 @@ A :class:`Cmd` instance has the following methods:
.. method:: Cmd.emptyline()

Method called when an empty line is entered in response to the prompt. If this
method is not overridden, it repeats the last nonempty command entered.
method is not overridden, it repeats the last nonempty command entered. To
suppress this behavior, override with a method that does nothing (``pass``).


.. method:: Cmd.default(line)
Expand Down Expand Up @@ -306,6 +309,16 @@ immediate playback::
bye()
return True

# ----- shell behavior -----
def emptyline(self):
'Do not repeat the last command on empty input'
pass
def do_EOF(self, arg):
'Exit on EOF (Ctrl-D): EOF'
print()
self.close()
return True

# ----- record and playback -----
def do_record(self, arg):
'Save future commands to filename: RECORD rose.cmd'
Expand Down
Loading