Skip to content

Leave emoji out of the stats summary in plain mode - #2311

Open
HardMax71 wants to merge 2 commits into
lycheeverse:masterfrom
HardMax71:plain-mode-without-emoji
Open

HardMax71 wants to merge 2 commits into
lycheeverse:masterfrom
HardMax71:plain-mode-without-emoji

Conversation

@HardMax71

@HardMax71 HardMax71 commented Sep 27, 2026 •

Copy link
Copy Markdown

Fixes #2310.

In --mode plain the compact and detailed stats now print their labels without emoji: the summary line, the Suggestions header, the detailed Summary block and the Per-host Statistics heading. Other modes print exactly what they did before. The host stats formatters drop Display for a format(mode) method that adds the 📊 prefix outside plain mode. The compact and detailed response stats already carry the mode, so they leave their symbols out themselves.

$ lychee --offline --no-progress --mode plain README.md
...
2 Total (in 3ms) 2 Unique 1 OK 1 Error
$ lychee --offline --no-progress --mode emoji README.md
...
🔍 2 Total (in 2ms) 🔗 2 Unique ✅ 1 OK 🚫 1 Error

Colors are left alone, since console already drops them for pipes and NO_COLOR.

The four formatter tests that run with OutputMode::Plain now expect the plain labels, and two new tests check that emoji mode keeps the symbols. cargo test for the formatters, cargo clippy --all-targets --all-features -- -D warnings and cargo fmt --check pass.

Copilot AI lite review requested due to automatic review settings September 27, 2026 09:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@mre

mre commented Sep 28, 2026

Copy link
Copy Markdown
Member

Thanks for looking into this. My first intuition is that the helper function is a bit of an antipattern here because it's quite "imperative."

The alternative would be to encapsulate the logic in the Stats structs themselves.

We can remove the Display impl on CompactHostStats/DetailedHostStats and instead have a method, which takes the OutputMode as an argument.

const STATS_EMOJI: &str = "📊";

impl CompactHostStats {
  fn format(mode: OutputMode) -> String {
    let mut buf = String::new();
    if *mode == OutputMode::Plain {
      buf.push(STATS_EMOJI);
    }
    // rest of the old logic
  }
}

Same for DetailedHostStats. wdyt?

CompactHostStats and DetailedHostStats drop Display for a format(mode) method that adds the 📊 prefix outside plain mode. The response stats already carry the mode, so they decide locally, and the shared icon helper is gone.
@HardMax71

Copy link
Copy Markdown
Author

Makes sense, done in 2677ce1. CompactHostStats and DetailedHostStats now have format(&self, mode: &OutputMode) instead of Display and push STATS_EMOJI only outside plain mode. It returns Result<String, fmt::Error> since the old body still writes with writeln!. The helper is gone.

The response stats structs already had the mode, so each one makes the same check inside its own fmt for now. I can move them to the format(mode) shape too if you want it the same everywhere.

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.

--mode plain still prints emoji in the stats summary

3 participants