Skip to content

Commit 4facf30

Browse files
committed
docs(cmd): highlight default empty-line command repetition
1 parent fca7fec commit 4facf30

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Doc/library/cmd.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ A :class:`Cmd` instance has the following methods:
9393
are the beginning and ending indexes of the prefix text, which could be used to
9494
provide different completion depending upon which position the argument is in.
9595

96+
.. rubric:: Empty input behavior
97+
98+
When the user enters an empty line in response to the prompt, ``Cmd`` does
99+
**not** ignore the input by default. Instead, it repeats the last non-empty
100+
command entered.
101+
102+
This behavior is implemented by :meth:`Cmd.emptyline`. Subclasses that do not
103+
want empty input to repeat the previous command should override
104+
:meth:`Cmd.emptyline` to do nothing::
105+
106+
def emptyline(self):
107+
pass
96108

97109
.. method:: Cmd.do_help(arg)
98110

0 commit comments

Comments
 (0)