Skip to content

Commit 41da03c

Browse files
committed
feedback_to_output now defaults to False
This is so that non-essential info which isn't directly associated with command output, such as time elapsed while executing a command, won't redirect when command output is redirected using >, >>, or |.
1 parent 499fdd6 commit 41da03c

7 files changed

Lines changed: 29 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
* Bug Fixes
44
* Added workaround for bug which occurs in Python 2.7 on Linux when ``pygtk`` is installed
5+
* ``pfeedback()`` now honors feedback_to_output setting and won't redirect when it is ``False``
6+
* For ``edit`` command, both **editor** and **filename** can now have spaces in the name/path
7+
* Enhancements
8+
* ``feedback_to_output`` now defaults to ``False`` so info like command timing won't redirect
59

610
## 0.7.6 (August 11, 2017)
711

cmd2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ class Cmd(cmd.Cmd):
470470
for editor in ['vim', 'vi', 'emacs', 'nano', 'pico', 'gedit', 'kate', 'subl', 'geany', 'atom']:
471471
if _which(editor):
472472
break
473-
feedback_to_output = True # Do include nonessentials in >, | output
473+
feedback_to_output = False # Do not include nonessentials in >, | output by default (things like timing)
474474
locals_in_py = True
475475
quiet = False # Do not suppress nonessential output
476476
timing = False # Prints elapsed time for each command

examples/transcript_regex.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Run this transcript with "python example.py -t transcript_regex.txt"
22
# The regex for colors is because no color on Windows.
3-
# The regex for editor will match whatever program you use.
3+
# The regex for editor will match whatever program you use.
44
(Cmd) set
55
abbrev: True
66
autorun_on_edit: False
@@ -9,7 +9,7 @@ continuation_prompt: >
99
debug: False
1010
echo: False
1111
editor: /.*/
12-
feedback_to_output: True
12+
feedback_to_output: False
1313
locals_in_py: True
1414
maxrepeats: 3
1515
prompt: (Cmd)

tests/conftest.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
debug: False
5555
echo: False
5656
editor: vim
57-
feedback_to_output: True
57+
feedback_to_output: False
5858
locals_in_py: True
5959
prompt: (Cmd)
6060
quiet: False
@@ -66,18 +66,18 @@
6666
else:
6767
color_str = 'False'
6868
SHOW_LONG = """
69-
abbrev: False # Accept abbreviated commands
70-
autorun_on_edit: False # Automatically run files after editing
71-
colors: {} # Colorized output (*nix only)
72-
continuation_prompt: > # On 2nd+ line of input
73-
debug: False # Show full error stack on error
74-
echo: False # Echo command issued into output
75-
editor: vim # Program used by ``edit``
76-
feedback_to_output: True # Include nonessentials in `|`, `>` results
77-
locals_in_py: True # Allow access to your application in py via self
78-
prompt: (Cmd) # The prompt issued to solicit input
79-
quiet: False # Don't print nonessential feedback
80-
timing: False # Report execution times
69+
abbrev: False # Accept abbreviated commands
70+
autorun_on_edit: False # Automatically run files after editing
71+
colors: {} # Colorized output (*nix only)
72+
continuation_prompt: > # On 2nd+ line of input
73+
debug: False # Show full error stack on error
74+
echo: False # Echo command issued into output
75+
editor: vim # Program used by ``edit``
76+
feedback_to_output: False # Include nonessentials in `|`, `>` results
77+
locals_in_py: True # Allow access to your application in py via self
78+
prompt: (Cmd) # The prompt issued to solicit input
79+
quiet: False # Don't print nonessential feedback
80+
timing: False # Report execution times
8181
""".format(color_str)
8282

8383

tests/test_cmd2.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ def test_relative_load_requires_an_argument(base_app, capsys):
427427
def test_base_save(base_app):
428428
# TODO: Use a temporary directory for the file
429429
filename = 'deleteme.txt'
430+
base_app.feedback_to_output = True
430431
run_cmd(base_app, 'help')
431432
run_cmd(base_app, 'help save')
432433

@@ -472,6 +473,7 @@ def test_save_parse_error(base_app, capsys):
472473

473474
def test_save_tempfile(base_app):
474475
# Just run help to make sure there is something in the history
476+
base_app.feedback_to_output = True
475477
run_cmd(base_app, 'help')
476478
out = run_cmd(base_app, 'save *')
477479
output = out[0]
@@ -507,7 +509,7 @@ def test_save_invalid_path(base_app, capsys):
507509
def test_output_redirection(base_app):
508510
fd, filename = tempfile.mkstemp(prefix='cmd2_test', suffix='.txt')
509511
os.close(fd)
510-
512+
511513
try:
512514
# Verify that writing to a file works
513515
run_cmd(base_app, 'help > {}'.format(filename))
@@ -533,7 +535,7 @@ def test_feedback_to_output_true(base_app):
533535
base_app.timing = True
534536
f, filename = tempfile.mkstemp(prefix='cmd2_test', suffix='.txt')
535537
os.close(f)
536-
538+
537539
try:
538540
run_cmd(base_app, 'help > {}'.format(filename))
539541
with open(filename) as f:
@@ -550,7 +552,7 @@ def test_feedback_to_output_false(base_app, capsys):
550552
base_app.timing = True
551553
f, filename = tempfile.mkstemp(prefix='feedback_to_output', suffix='.txt')
552554
os.close(f)
553-
555+
554556
try:
555557
run_cmd(base_app, 'help > {}'.format(filename))
556558
out, err = capsys.readouterr()
@@ -1253,12 +1255,14 @@ def test_clipboard_failure(capsys):
12531255

12541256
def test_run_command_with_empty_arg(base_app):
12551257
command = 'help'
1258+
base_app.feedback_to_output = True
12561259
run_cmd(base_app, command)
12571260
out = run_cmd(base_app, 'run')
12581261
expected = normalize('{}\n\n'.format(command) + BASE_HELP)
12591262
assert out == expected
12601263

12611264
def test_run_command_with_empty_history(base_app):
1265+
base_app.feedback_to_output = True
12621266
out = run_cmd(base_app, 'run')
12631267
assert out == []
12641268

tests/test_transcript.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ def test_base_with_transcript(_cmdline_app):
150150
-------------------------[6]
151151
say -ps --repeat=5 goodnight, Gracie
152152
(Cmd) run 4
153-
say -ps --repeat=5 goodnight, Gracie
154153
OODNIGHT, GRACIEGAY
155154
OODNIGHT, GRACIEGAY
156155
OODNIGHT, GRACIEGAY
@@ -237,6 +236,7 @@ def test_commands_at_invocation():
237236
def test_transcript_from_cmdloop(request, capsys):
238237
# Create a cmd2.Cmd() instance and make sure basic settings are like we want for test
239238
app = CmdLineApp()
239+
app.feedback_to_output = True
240240

241241
# Get location of the transcript
242242
test_dir = os.path.dirname(request.module.__file__)

tests/transcript_regex.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ continuation_prompt: >
99
debug: False
1010
echo: False
1111
editor: /.*/
12-
feedback_to_output: True
12+
feedback_to_output: False
1313
locals_in_py: True
1414
maxrepeats: 3
1515
prompt: (Cmd)

0 commit comments

Comments
 (0)