fix(cli): respect -q flag in mise prepare command#8792
Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces custom miseprintln! macros with standard logging macros such as info! and warn! within the prepare command. The feedback suggests using error! instead of warn! for failed steps to ensure that failure messages remain visible even when the log level is restricted, such as in quiet mode.
Greptile SummaryThis PR fixes the Key changes:
Confidence Score: 5/5Safe to merge — the fix is narrowly scoped and correct, and the e2e tests are consistently updated to capture stderr output. No P0/P1 issues identified that were not already discussed in prior review threads. The use of error!() for Failed steps ensures failures are visible even in quiet mode (quiet sets log_level to 'error', not 'off'), addressing the main concern from the previous thread. All e2e tests correctly add 2>&1 to capture the now-stderr output from the logging macros. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["mise prepare run()"] --> B{Check result steps}
B -->|PrepareStepResult::Ran| C["info!('Prepared: {id}')"]
B -->|PrepareStepResult::WouldRun| D["info!('[dry-run] Would prepare: {id} ({reason})')"]
B -->|PrepareStepResult::Fresh| E["debug!('Fresh: {id}')"]
B -->|PrepareStepResult::Skipped| F["debug!('Skipped: {id}')"]
B -->|PrepareStepResult::Failed| G["error!('Failed: {id}')"]
C --> H{All steps done?}
D --> H
E --> H
F --> H
G --> H
H -->|!had_work && !dry_run| I["info!('All dependencies are up to date')"]
H -->|otherwise| J["return Ok(())"]
I --> J
subgraph Logger["logger.rs (term_level)"]
K["quiet=true → log_level='error'"]
L["info! filtered out"]
M["error! shown on stderr"]
end
C -.->|routed through| Logger
D -.->|routed through| Logger
G -.->|routed through| Logger
I -.->|routed through| Logger
Reviews (4): Last reviewed commit: "test: update e2e prepare tests" | Re-trigger Greptile |
### 🚀 Features - **(install)** add per-tool install_before option by @sargunv-headway in [#8842](#8842) ### 🐛 Bug Fixes - **(cli)** respect `-q` flag in `mise prepare` command by @Marukome0743 in [#8792](#8792) - fall back to compile-time musl detection when no system linker found by @davireis in [#8825](#8825) ### 📚 Documentation - fix GitHub capitalization in Alpine docs by @Rohan5commit in [#8844](#8844) ### 📦 Registry - add dbt-fusion ([aqua:getdbt.com/dbt-fusion](https://github.com/getdbt.com/dbt-fusion)) by @ryan-pip in [#8837](#8837) ### New Contributors - @Marukome0743 made their first contribution in [#8792](#8792) - @sargunv-headway made their first contribution in [#8842](#8842) - @Rohan5commit made their first contribution in [#8844](#8844) - @ryan-pip made their first contribution in [#8837](#8837) - @rndmh3ro made their first contribution in [#8839](#8839) ## 📦 Aqua Registry Updates #### New Packages (1) - [`azu/dockerfile-pin`](https://github.com/azu/dockerfile-pin) #### Updated Packages (4) - [`anthropics/claude-code`](https://github.com/anthropics/claude-code) - [`dandavison/delta`](https://github.com/dandavison/delta) - [`goreleaser/goreleaser`](https://github.com/goreleaser/goreleaser) - [`zellij-org/zellij`](https://github.com/zellij-org/zellij)
## Summary Follow-up to [#8792](#8792). After `mise prepare` was renamed to `mise deps`, `-q` started leaking provider command output again — running `mise deps install -q` against e.g. a `bundler` provider still streams `bundle install`'s stdout/stderr through the prefix-tagged tee in the deps engine. \#8792 fixed the *summary* path (`Prepared:`/`Failed:`/`All dependencies are up to date`) by routing it through the logger via `info!`/`error!`, and that change carried over to `src/cli/deps/install.rs` after the rename. But the provider **command stream** is a separate path that bypasses the logger entirely, so `-q` never had any effect on it. ## Root cause In `src/deps/engine.rs::execute_command`, the `with_on_stdout` / `with_on_stderr` callbacks unconditionally write captured lines via `prefix_println!` / `prefix_eprintln!`. Both macros expand to `calm_io::stdoutln!` / `calm_io::stderrln!` and never consult `Settings::quiet`, so the quiet flag passes straight through. `mise install -q` does not have this issue because the install path uses `with_pr(...)` and routes output through `MultiProgressReport::add`, which returns a `QuietReport` (no-op `println` / `set_message`) when `Settings::quiet` is set. The deps engine instead sets explicit `on_stdout` / `on_stderr` callbacks that take precedence over the `pr` fallback in `CmdLineRunner` — so the `QuietReport` never sees the streamed lines. ## Fix Read `Settings::get().quiet` once before the closures and skip the `prefix_println!` / `prefix_eprintln!` calls when set. The `progress.set_message` call is left in place: it is a no-op for `QuietReport` and still drives the spinner under `ProgressReport` in normal mode. This matches `mise install -q` behavior — the provider command stream is suppressed, while logger-routed status (`Installed:`, `Failed:`) continues to follow the normal quiet level (errors only). ## Test plan - [x] Added a regression assertion in `e2e/cli/test_deps`: with the existing `codegen` provider, `mise deps --force --only codegen -q` must contain neither the prefix-tagged stream output (`[deps.codegen]`) nor the info-level summary (`Installed:`). The assertion immediately above the new lines proves the same command without `-q` *does* emit `[deps.codegen] codegen`, so the pair anchors both directions. - [x] `mise run test:e2e cli/test_deps cli/test_deps_depends cli/test_deps_tool_install` — could not run on this Windows machine (no MSVC `link.exe`, so even `cargo check` fails to link build scripts). Relying on CI for full verification. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
The global
-q(--quiet) flag was not suppressing status messages inmise prepare.This is because the command used
miseprintln!()for result reporting, which writesdirectly to stdout and bypasses the logging system entirely.
Problem
When running
mise prepare -q, messages like the following were still printed:Prepared: <provider>[dry-run] Would prepare: <provider> (<reason>)Failed: <provider>All dependencies are up to dateIn contrast,
mise install -qcorrectly suppresses all non-error output because it usesinfo!()/warn!()macros that go through the logger, which checksSettings::quietand sets
log_levelto"error"accordingly.Root Cause
miseprintln!()expands tocalm_io::stdoutln!()and has no awareness of the quiet flag.The logging macros (
info!(),warn!(),debug!()) route through the logger insrc/logger.rs, which respects theterm_levelderived fromSettings::quiet.Changes
In
src/cli/prepare.rs, replacedmiseprintln!()with appropriate logging macros in therun()method's result reporting section:Prepared: {id}miseprintln!info![dry-run] Would prepare: ...miseprintln!info!Failed: {id}miseprintln!error!All dependencies are up to datemiseprintln!info!The
--explainand--listsubcommand outputs remain usingmiseprintln!()intentionally,since those are explicitly requested by the user and should always be displayed regardless
of the
-qflag.