Skip to content

#1627: Consolidated set command output and added support for quiet mode#1647

Open
bambu wants to merge 3 commits intomainfrom
1627-silence-settable
Open

#1627: Consolidated set command output and added support for quiet mode#1647
bambu wants to merge 3 commits intomainfrom
1627-silence-settable

Conversation

@bambu
Copy link
Copy Markdown
Contributor

@bambu bambu commented Apr 23, 2026

Description

Improve user experience of the set command by consolidating output into 1 line and allowing for the output to be hidden when quiet is set. The previous output was overly verbose (three lines) and could not be silenced.

Changes

  • Consolidated Output: The set command now produces a clean, single-line confirmation instead of the previous three-line format.
  • Colorized Diffs: The old value is displayed in red and the new value in green, providing a clear visual diff of the change.
  • Quiet Mode Support: Switched the output from poutput() to pfeedback(). This allows the set command's change confirmation to be silenced entirely when the quiet settable is enabled, while remaining noisy by default.
  • Unit Tests: Updated tests/test_cmd2.py and tests/test_commandset.py

Example Behavior

   # Default behavior (noisy, consolidated, colorized)
   (CLI)> set timing True
   timing: False -> True

   # Silent when quiet mode is enabled
   (CLI)> set quiet True
   (CLI)> set timing False
   # (No output produced)

Closes #1627

bambu added 3 commits April 22, 2026 09:48
…utput. (#1627)

* Made the set command silent on success by default.
* Added a -v/--verbose flag to the set command to display change confirmations.
* Consolidated the verbose output into a single, colorized line (e.g., param: old -> new).
* Updated unit tests to reflect the new default behavior and output format.
* Updated do_set to use pfeedback for change confirmations, allowing it to be silenced via the quiet setting.
* Updated unit tests to match the new output format and verify quiet mode behavior.
@bambu bambu self-assigned this Apr 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.49%. Comparing base (03db5e4) to head (58a3aa4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1647      +/-   ##
==========================================
+ Coverage   99.47%   99.49%   +0.02%     
==========================================
  Files          21       21              
  Lines        4758     4759       +1     
==========================================
+ Hits         4733     4735       +2     
+ Misses         25       24       -1     
Flag Coverage Δ
unittests 99.49% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kmvanbrunt
Copy link
Copy Markdown
Member

@bambu I need to consider this. I don't think the previous output was too verbose. I'm OK if we reformat it, but the amount of information displayed was, in my view, reasonable.

I'm also concerned about the new output being on one line. A settable could be anything, including an entire command line to run a tool. If we are still going to display both the previous and new value, I think they need to be on separate lines.

Help me understand the reason behind this change. Are you running set a lot in scripts and seeing a lot of output or something?

Comment thread cmd2/cmd2.py
(f"{settable.value!r}", "green"),
)
self.pfeedback(feedback_msg)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see 3 fundamental distinct changes here:

  1. Output is more abbreviated - 1 line instead of 2
  2. Previous and new values are colorized to enhance readability as a diff
  3. pfeedback is used instead of poutput

In general I think the later two are unquestionably welcome changes.

For most use cases I like the more succinct single-line output format. However, I can envision a theoretical edge case where both the old and new values are many characters such that fitting on a single line might be problematic. I'd be fine with a 2-line solution or with an intelligent splitting based on terminal width.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settable output is overly verbose and lacks a silent mode

3 participants