#2042: quiet modus supression for question - #2228
Conversation
…bug/2042_quiet_modus_supression_for_question # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
quando632
left a comment
There was a problem hiding this comment.
Thanks for tackling this. The one line change does fix the reported symptom: with the threshold at INTERACTION, both the question from cveCheck and the option list are visible under -q.
Since only ContextCommandlet.java is part of the diff, GitHub does not let me attach applyable suggestions to the other files, so the proposed changes are inlined below.
On the chosen approach
The fix works, but it deviates from the guidance in the issue, which says: "IMHO INTERACTION has to be raised to be after WARNING." This PR lowers the quiet threshold instead and leaves the enum order untouched.
Two points on that:
-
The underlying design flaw remains. Any code path that sets the threshold to WARNING or higher will still swallow prompts. This is not theoretical: see the existing workaround in
AbstractIdeContextlines 1480 to 1485, where the log level is temporarily lowered to INFO just so the license question becomes visible.runWithoutLogging(lambda, threshold)can also set arbitrary thresholds. -
The functional difference is not just cosmetic. With this variant SUCCESS also becomes visible under
-q, while the enum reordering would keep it suppressed. Affected messages includeIDE_ROOT is set to ...,IDE_HOME is set to ...,You are online.,Found bash executable at: ...and allstep.success()output. This does match the documented behaviour of the flag, but it is a noticeable change for anyone using-qto keep output small.
Please either reorder the enum to ... SUCCESS, WARNING, INTERACTION, ERROR, PROCESSABLE and keep quiet = WARNING, or briefly explain in the PR why this variant was chosen and align it with @hohwille.
1. Duplicate question logging
cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java line 1087
The question is logged twice: once at INTERACTION and once as WARN. The WARN line used to be the workaround so that at least the question text showed up under -q. Now that INTERACTION is visible in quiet mode, the question is printed twice, in normal mode as well as in quiet mode. This line should be removed as part of this fix.
assert (options.length > 0);
IdeLogLevel.INTERACTION.log(LOG, question, args);
LOG.warn(question, args); // <- remove this line
return displayOptionsAndGetAnswer(options);2. English help text
cli/src/main/resources/nls/Help.properties line 188
The help text no longer describes the actual behaviour. Interactive questions are now visible too.
opt.--quiet=disable info logging (only log interaction, success, warning or error).3. German help text
cli/src/main/resources/nls/Help_de.properties line 188
Same change as in the English file. The stray space after the opening bracket is fixed along the way.
opt.--quiet=Deaktiviert Info Logging (nur interaction, success, warning und error).4. Missing CHANGELOG entry
CHANGELOG.adoc, section == 2026.08.001
The DoD requires an entry for the issue in the next open release. This change is visible to end users.
* https://github.com/devonfw/IDEasy/issues/2100[#2100]: Fix Python not available for Mac x64
* https://github.com/devonfw/IDEasy/issues/2042[#2042]: -q parameter no longer suppresses interactive questions5. Missing test
cli/src/test/java/com/devonfw/tools/ide/commandlet/ContextCommandletTest.java
The bugfix has no test. Without an assertion on the log level a revert would go unnoticed. testRunWithOptions() already sets --quiet, only the check is missing.
Add the import:
import com.devonfw.tools.ide.log.IdeLogLevel;And the assertion at the end of testRunWithOptions():
assertThat(cxt.getStartContext().getLogLevelConsole()).isEqualTo(IdeLogLevel.INTERACTION);On top of that, an end to end test via IdeTestContext would be useful: run a question(...) in quiet mode and assert that both the question and the option list are logged, and that the question is logged only once.
This PR fixes #2042
Implemented changes:
Changed the log level in quiet modus
Testing instructions
Checklist for this PR
Make sure everything is checked before merging this PR. For further info please also see
our DoD.
mvn clean testlocally all tests pass and build is successful ✅#«issue-id»: «brief summary»(e.g.#921: fixed setup.bat). If no issue ID exists, title only.✅In Progressand assigned to you or there is no issue (might happen for very small PRs)✅with
internal✅