fix(cli): prevent crash when parsing stdin

When we are parsing stdin via a pipe or heredoc, the source count is 0
(unsigned) so the XML output crashes while trying to subtract from it.
This commit is contained in:
ObserverOfTime 2025-10-01 09:33:38 +03:00
parent 1dc4804b6e
commit 0cf6e7c507

View file

@ -230,13 +230,23 @@ impl ParseSummary {
}
}
#[derive(Serialize, Debug, Default)]
#[derive(Serialize, Debug)]
pub struct ParseStats {
pub parse_summaries: Vec<ParseSummary>,
pub cumulative_stats: Stats,
pub source_count: usize,
}
impl Default for ParseStats {
fn default() -> Self {
Self {
parse_summaries: Vec::new(),
cumulative_stats: Stats::default(),
source_count: 1,
}
}
}
#[derive(Serialize, ValueEnum, Debug, Copy, Clone, Default, Eq, PartialEq)]
pub enum ParseDebugType {
#[default]