Skip to content

Commit 525f4ca

Browse files
authored
Merge pull request #168 from python-cmd2/remove_pause
Removed pause command
2 parents b06c95b + 29eeb89 commit 525f4ca

File tree

8 files changed

+51
-42
lines changed

8 files changed

+51
-42
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,8 @@ example/exampleSession.txt:
189189
190190
Documented commands (type help <topic>):
191191
========================================
192-
_relative_load help orate pyscript save shell speak
193-
cmdenvironment history pause quit say shortcuts
194-
edit load py run set show
192+
_relative_load edit history orate pyscript run say shell show
193+
cmdenvironment help load py quit save set shortcuts speak
195194
196195
(Cmd) help say
197196
Repeats what you tell me to.

cmd2.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,13 +1128,6 @@ def do_set(self, arg):
11281128
except (ValueError, AttributeError):
11291129
self.do_show(arg)
11301130

1131-
# noinspection PyMethodMayBeStatic
1132-
def do_pause(self, text):
1133-
"""Displays the specified text then waits for the user to press <Enter>.
1134-
1135-
Usage: pause [text]"""
1136-
sm.input(text + '\n')
1137-
11381131
def do_shell(self, command):
11391132
"""Execute a command as if at the OS prompt.
11401133
@@ -2276,7 +2269,37 @@ def __nonzero__(self):
22762269

22772270
if __name__ == '__main__':
22782271
# If run as the main application, simply start a bare-bones cmd2 application with only built-in functionality.
2279-
# But enable the ipy command if IPython is installed, which supports advanced interactive debugging of your app,
2280-
# via introspection on self.
2281-
app = Cmd(use_ipython=True)
2272+
2273+
# Set this to True to include the ipy command if IPython is installed, which supports advanced interactive debugging
2274+
# of your application via introspection on self.
2275+
# include_ipy = False
2276+
#
2277+
# app = Cmd(use_ipython=include_ipy)
2278+
# app.cmdloop()
2279+
2280+
2281+
class HelpApp(Cmd):
2282+
"""Class for testing custom help_* methods which override docstring help."""
2283+
2284+
def __init__(self, *args, **kwargs):
2285+
# Need to use this older form of invoking super class constructor to support Python 2.x and Python 3.x
2286+
Cmd.__init__(self, *args, **kwargs)
2287+
2288+
def do_squat(self, arg):
2289+
"""This docstring help will never be shown because the help_squat method overrides it."""
2290+
pass
2291+
2292+
def help_squat(self):
2293+
self.stdout.write('This command does diddly squat...\n')
2294+
2295+
def do_edit(self, arg):
2296+
"""This overrides the edit command and does nothing."""
2297+
pass
2298+
2299+
# This command will be in the "undocumented" section of the help menu
2300+
def do_undoc(self, arg):
2301+
pass
2302+
2303+
2304+
app = HelpApp()
22822305
app.cmdloop()

docs/freefeatures.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,6 @@ with automatically included ``do_`` methods.
286286

287287
.. automethod:: cmd2.Cmd.do_quit
288288

289-
.. automethod:: cmd2.Cmd.do_pause
290-
291289
.. automethod:: cmd2.Cmd.do_shell
292290

293291
( ``!`` is a shortcut for ``shell``; thus ``!ls``

examples/exampleSession.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
Documented commands (type help <topic>):
55
========================================
6-
_relative_load help orate pyscript save shell speak
7-
cmdenvironment history pause quit say shortcuts
8-
edit load py run set show
6+
_relative_load edit history orate pyscript run say shell show
7+
cmdenvironment help load py quit save set shortcuts speak
98

109
(Cmd) help say
1110
Repeats what you tell me to.

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# Help text for base cmd2.Cmd application
1616
BASE_HELP = """Documented commands (type help <topic>):
1717
========================================
18-
_relative_load edit history pause pyscript run set shortcuts
19-
cmdenvironment help load py quit save shell show
18+
_relative_load edit history py quit save shell show
19+
cmdenvironment help load pyscript run set shortcuts
2020
"""
2121

2222
# Help text for the history command

tests/test_cmd2.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,6 @@ def test_base_error(base_app):
182182
assert out == ["*** Unknown syntax: meow"]
183183

184184

185-
def test_base_pause(base_app):
186-
# Mock out the input call so we don't actually wait for a user's response on stdin
187-
m = mock.MagicMock(name='input', return_value='\n')
188-
sm.input = m
189-
190-
run_cmd(base_app, 'pause')
191-
m.assert_called_once()
192-
193185
def test_base_history(base_app):
194186
run_cmd(base_app, 'help')
195187
run_cmd(base_app, 'shortcuts')
@@ -556,9 +548,9 @@ def test_pipe_to_shell(base_app):
556548
# Windows
557549
# Get help menu and pipe it's output to the sort shell command
558550
out = run_cmd(base_app, 'help | sort')
559-
expected = ['', '', '_relative_load edit history pause pyscript run set shortcuts',
551+
expected = ['', '', '_relative_load edit history py quit save shell show',
560552
'========================================',
561-
'cmdenvironment help load py quit save shell show',
553+
'cmdenvironment help load pyscript run set shortcuts',
562554
'Documented commands (type help <topic>):']
563555
assert out == expected
564556
else:
@@ -870,8 +862,8 @@ def do_squat(self, arg):
870862
def help_squat(self):
871863
self.stdout.write('This command does diddly squat...\n')
872864

873-
def do_pause(self, arg):
874-
"""This overrides the pause command and does nothing."""
865+
def do_edit(self, arg):
866+
"""This overrides the edit command and does nothing."""
875867
pass
876868

877869
# This command will be in the "undocumented" section of the help menu
@@ -894,8 +886,8 @@ def test_custom_help_menu(help_app):
894886
expected = normalize("""
895887
Documented commands (type help <topic>):
896888
========================================
897-
_relative_load edit history pause pyscript run set shortcuts squat
898-
cmdenvironment help load py quit save shell show
889+
_relative_load edit history py quit save shell show
890+
cmdenvironment help load pyscript run set shortcuts squat
899891
900892
Undocumented commands:
901893
======================
@@ -909,8 +901,8 @@ def test_help_undocumented(help_app):
909901
assert out == expected
910902

911903
def test_help_overridden_method(help_app):
912-
out = run_cmd(help_app, 'help pause')
913-
expected = normalize('This overrides the pause command and does nothing.')
904+
out = run_cmd(help_app, 'help edit')
905+
expected = normalize('This overrides the edit command and does nothing.')
914906
assert out == expected
915907

916908

tests/test_transcript.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ def test_base_with_transcript(_cmdline_app):
106106
107107
Documented commands (type help <topic>):
108108
========================================
109-
_relative_load help orate pyscript save shell speak
110-
cmdenvironment history pause quit say shortcuts
111-
edit load py run set show
109+
_relative_load edit history orate pyscript run say shell show
110+
cmdenvironment help load py quit save set shortcuts speak
112111
113112
(Cmd) help say
114113
Repeats what you tell me to.

tests/transcript.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
Documented commands (type help <topic>):
44
========================================
5-
_relative_load help orate pyscript save shell speak
6-
cmdenvironment history pause quit say shortcuts
7-
edit load py run set show
5+
_relative_load edit history orate pyscript run say shell show
6+
cmdenvironment help load py quit save set shortcuts speak
87

98
(Cmd) help say
109
Repeats what you tell me to.

0 commit comments

Comments
 (0)