mirror of
https://github.com/Hopiu/lychee.git
synced 2026-04-19 12:41:14 +00:00
Remove inaccurate details in compact view (#1088)
This commit is contained in:
parent
cbda328129
commit
3c3051a7f0
1 changed files with 2 additions and 30 deletions
|
|
@ -1,10 +1,7 @@
|
|||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::{self, Display},
|
||||
};
|
||||
use std::fmt::{self, Display};
|
||||
|
||||
use crate::{
|
||||
color::{color, BOLD_GREEN, BOLD_PINK, BOLD_YELLOW, NORMAL, PINK},
|
||||
color::{color, BOLD_GREEN, BOLD_PINK, BOLD_YELLOW, NORMAL},
|
||||
formatters::color_response,
|
||||
stats::ResponseStats,
|
||||
};
|
||||
|
|
@ -15,27 +12,6 @@ use anyhow::Result;
|
|||
|
||||
struct CompactResponseStats(ResponseStats);
|
||||
|
||||
// Helper function, which prints the detailed list of errors
|
||||
pub(crate) fn print_errors(stats: &ResponseStats) -> String {
|
||||
let mut errors = HashMap::new();
|
||||
errors.insert(
|
||||
"HTTP",
|
||||
stats.errors - stats.redirects - stats.timeouts - stats.unknown,
|
||||
);
|
||||
errors.insert("Redirects", stats.redirects);
|
||||
errors.insert("Timeouts", stats.timeouts);
|
||||
errors.insert("Unknown", stats.unknown);
|
||||
|
||||
// Creates an output like `(HTTP:3|Timeouts:1|Unknown:1)`
|
||||
let mut err: Vec<_> = errors
|
||||
.into_iter()
|
||||
.filter(|(_, v)| *v > 0)
|
||||
.map(|(k, v)| format!("{k}:{v}"))
|
||||
.collect();
|
||||
err.sort();
|
||||
err.join("|")
|
||||
}
|
||||
|
||||
impl Display for CompactResponseStats {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let stats = &self.0;
|
||||
|
|
@ -77,10 +53,6 @@ impl Display for CompactResponseStats {
|
|||
|
||||
let err_str = if total_errors == 1 { "Error" } else { "Errors" };
|
||||
color!(f, BOLD_PINK, " \u{1f6ab} {} {}", total_errors, err_str)?;
|
||||
if total_errors > 0 {
|
||||
write!(f, " ")?;
|
||||
color!(f, PINK, "({})", print_errors(stats))?;
|
||||
}
|
||||
if stats.excludes > 0 {
|
||||
color!(f, BOLD_YELLOW, " \u{1F4A4} {} Excluded", stats.excludes)?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue