add warnings for empty groups and sections
This commit is contained in:
+11
-2
@@ -79,11 +79,20 @@ impl Group {
|
|||||||
let mut sections = HashSet::new();
|
let mut sections = HashSet::new();
|
||||||
|
|
||||||
while lines.peek().is_some() {
|
while lines.peek().is_some() {
|
||||||
if let Ok(section) = Section::try_from_lines(&mut lines).context("reading section") {
|
match Section::try_from_lines(&mut lines).context("reading section") {
|
||||||
sections.insert(section);
|
Ok(section) => {
|
||||||
|
sections.insert(section);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("WARNING: could not process a section under group '{name}': {e:?}\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sections.is_empty() {
|
||||||
|
println!("WARNING: no sections found in group '{name}'");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(Self { name, sections })
|
Ok(Self { name, sections })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -5,7 +5,7 @@ use std::{
|
|||||||
iter::Peekable,
|
iter::Peekable,
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{ensure, Context, Result};
|
||||||
|
|
||||||
use crate::Package;
|
use crate::Package;
|
||||||
|
|
||||||
@@ -38,6 +38,9 @@ impl Section {
|
|||||||
packages.insert(package);
|
packages.insert(package);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensure!(!packages.is_empty());
|
||||||
|
|
||||||
Ok(Self::new(name, packages))
|
Ok(Self::new(name, packages))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user