use deb822_lossless::TextRange;
use debian_control::lossless::Control;
fn main() {
let control_text = r#"Source: example-package
Maintainer: John Doe <john@example.com>
Build-Depends: debhelper (>= 12)
Package: example-binary
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Example package
This is an example package
with a multi-line description.
"#;
let control: Control = control_text.parse().unwrap();
let change_start = control_text.find("Architecture:").unwrap();
let change_end = change_start + "Architecture: any".len();
let change_range = TextRange::new((change_start as u32).into(), (change_end as u32).into());
println!("Checking fields in range {}..{}", change_start, change_end);
println!("Fields affected by the change:");
for entry in control.fields_in_range(change_range) {
if let Some(key) = entry.key() {
println!(" - Field: {}", key);
let value = entry.value();
println!(" Value: {}", value.trim());
}
}
if let Some(source) = control.source() {
println!(
"\nSource paragraph overlaps with change: {}",
source.overlaps_range(change_range)
);
}
for binary in control.binaries() {
if let Some(name) = binary.name() {
println!(
"Binary '{}' overlaps with change: {}",
name,
binary.overlaps_range(change_range)
);
}
}
}