Repository navigation
Conversation
|
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 We can remove the 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 |
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.
|
Makes sense, done in 2677ce1. The response stats structs already had the mode, so each one makes the same check inside its own |
Fixes #2310.
In
--mode plainthe compact and detailed stats now print their labels without emoji: the summary line, theSuggestionsheader, the detailedSummaryblock and thePer-host Statisticsheading. Other modes print exactly what they did before. The host stats formatters dropDisplayfor aformat(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.Colors are left alone, since
consolealready drops them for pipes andNO_COLOR.The four formatter tests that run with
OutputMode::Plainnow expect the plain labels, and two new tests check that emoji mode keeps the symbols.cargo testfor the formatters,cargo clippy --all-targets --all-features -- -D warningsandcargo fmt --checkpass.