Skip to content

fix(cli): respect -q flag in mise prepare command#8792

Merged
jdx merged 3 commits intojdx:mainfrom
Marukome0743:fix/quiet
Apr 2, 2026
Merged

fix(cli): respect -q flag in mise prepare command#8792
jdx merged 3 commits intojdx:mainfrom
Marukome0743:fix/quiet

Conversation

@Marukome0743
Copy link
Copy Markdown
Contributor

@Marukome0743 Marukome0743 commented Mar 27, 2026

Summary

The global -q (--quiet) flag was not suppressing status messages in mise prepare.
This is because the command used miseprintln!() for result reporting, which writes
directly 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 date

In contrast, mise install -q correctly suppresses all non-error output because it uses
info!() / warn!() macros that go through the logger, which checks Settings::quiet
and sets log_level to "error" accordingly.

Root Cause

miseprintln!() expands to calm_io::stdoutln!() and has no awareness of the quiet flag.
The logging macros (info!(), warn!(), debug!()) route through the logger in
src/logger.rs, which respects the term_level derived from Settings::quiet.

Changes

In src/cli/prepare.rs, replaced miseprintln!() with appropriate logging macros in the
run() method's result reporting section:

Message Before After
Prepared: {id} miseprintln! info!
[dry-run] Would prepare: ... miseprintln! info!
Failed: {id} miseprintln! error!
All dependencies are up to date miseprintln! info!

The --explain and --list subcommand outputs remain using miseprintln!() intentionally,
since those are explicitly requested by the user and should always be displayed regardless
of the -q flag.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 27, 2026

Greptile Summary

This PR fixes the -q / --quiet flag not suppressing status messages in mise prepare by replacing miseprintln!() calls (which write unconditionally to stdout) with the appropriate logging macros (info!() for success messages, error!() for failure messages) that route through the log crate and respect the term_level derived from Settings::quiet. E2E tests are updated throughout to add 2>&1 to redirect stderr alongside stdout, since the logging infrastructure writes via eprintln!().

Key changes:

  • Prepared: {id}info!() (suppressed by -q)
  • [dry-run] Would prepare: {id} ({reason})info!() (suppressed by -q)
  • Failed: {id}error!() (correctly surfaces in quiet mode, since quiet sets log_level = "error" not "off")
  • All dependencies are up to dateinfo!() (suppressed by -q)
  • --explain and --list output intentionally kept on miseprintln!() (stdout, always shown)
  • All e2e test assertions on --dry-run and Prepared:/up to date output updated to add 2>&1

Confidence Score: 5/5

Safe 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

Filename Overview
src/cli/prepare.rs Core fix: replaces miseprintln!() with info!()/error!() macros for result reporting so the -q flag correctly suppresses non-error output; --explain and --list output intentionally remain on stdout via miseprintln!()
e2e/cli/test_prepare All assertions on command output that relied on stdout now correctly add 2>&1 to also capture stderr, since info!/error! macros route through the logger which writes to eprintln!(stderr)
e2e/cli/test_prepare_depends Single dry-run assertion updated with 2>&1 to capture stderr output from the logger
e2e/cli/test_prepare_tool_install Single Prepared: assertion updated with 2>&1 to capture info!() output from stderr

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
Loading

Reviews (4): Last reviewed commit: "test: update e2e prepare tests" | Re-trigger Greptile

@jdx jdx merged commit 6f82ee6 into jdx:main Apr 2, 2026
34 checks passed
mise-en-dev added a commit that referenced this pull request Apr 2, 2026
### 🚀 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)
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.

2 participants