File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -1017,14 +1017,13 @@ def _cmdloop(self):
10171017 if self .cmdqueue :
10181018 # Run command out of cmdqueue if nonempty (populated by load command or commands at invocation)
10191019 line = self .cmdqueue .pop (0 )
1020+
1021+ if self .echo and line != 'eos' :
1022+ self .poutput ('{}{}' .format (self .prompt , line ))
10201023 else :
10211024 # Otherwise, read a command from stdin
10221025 line = self .pseudo_raw_input (self .prompt )
10231026
1024- # If echo is on and in the middle of running a script, then echo the line to the output
1025- if self .echo and self ._current_script_dir is not None :
1026- self .poutput (line + '\n ' )
1027-
10281027 # Run the command along with all associated pre and post hooks
10291028 stop = self .onecmd_plus_hooks (line )
10301029 finally :
Original file line number Diff line number Diff line change @@ -1372,7 +1372,8 @@ def test_echo(capsys):
13721372 app = cmd2 .Cmd ()
13731373 # Turn echo on and pre-stage some commands in the queue, simulating like we are in the middle of a script
13741374 app .echo = True
1375- app .cmdqueue = ['help history' , 'quit' , 'eos' ]
1375+ command = 'help history'
1376+ app .cmdqueue = [command , 'quit' , 'eos' ]
13761377 app ._script_dir .append ('some_dir' )
13771378
13781379 assert app ._current_script_dir is not None
@@ -1385,7 +1386,7 @@ def test_echo(capsys):
13851386 # Check the output
13861387 assert app .cmdqueue == []
13871388 assert app ._current_script_dir is None
1388- assert out .startswith ('help history \n ' + 'history [arg]: lists past commands issued' )
1389+ assert out .startswith ('{}{} \n ' . format ( app . prompt , command ) + 'history [arg]: lists past commands issued' )
13891390
13901391
13911392def test_raw_input (base_app ):
You can’t perform that action at this time.
0 commit comments