From b5026fbbcf5218b9e9bc6f01c8bd6b4f6def5809 Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Tue, 15 Sep 2026 14:54:53 -0400 Subject: [PATCH] style(human): match moria's run-stats footer format Normalize mithril's plain-text footer to moria's, so the two tools print identical run stats. The old single line Scanned 117 files (42558958 bytes) in 0.203 s is replaced with moria's aligned three-line block, upscaling the byte total to KB/MB/GB/TB (integer bytes, one decimal thereafter): Files analyzed: 117 Bytes analyzed: 40.6 MB Elapsed: 0.066 s Same upscale loop and label alignment as moria. JSON output is unaffected. --- src/main.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f40b7da..f2b7074 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -406,9 +406,20 @@ int main(int argc, char** argv) { std::fwrite(j.data(), 1, j.size(), stdout); std::fputc('\n', stdout); } else { - char foot[128]; - std::snprintf(foot, sizeof(foot), "Scanned %zu file%s (%zu bytes) in %.3f s", - rep.file_count, rep.file_count == 1 ? "" : "s", rep.bytes_scanned, secs); + // Run-stats footer, matching moria's format: file count, byte total + // upscaled to KB/MB/GB/TB (integer bytes, one decimal thereafter), and + // elapsed seconds. Aligned label column mirrors moria exactly. + double b = static_cast(rep.bytes_scanned); + const char* bu = "B"; + for (const char* u : {"KB", "MB", "GB", "TB"}) { + if (b < 1024.0) break; + b /= 1024.0; + bu = u; + } + char foot[256]; + std::snprintf(foot, sizeof(foot), + "Files analyzed: %zu\nBytes analyzed: %.*f %s\nElapsed: %.3f s", + rep.file_count, (*bu == 'B' ? 0 : 1), b, bu, secs); bool color = isatty(fileno(stdout)) && !std::getenv("NO_COLOR"); std::string h = emit_report_human(rep, impl, foot, color, license_paths, verbose); std::fwrite(h.data(), 1, h.size(), stdout);