Exit dmdoc --dry-run with an error count

This commit is contained in:
Tad Hardesty 2020-10-06 22:13:45 -07:00
parent 6a4d76600e
commit ff60f2cf1a

View file

@ -161,9 +161,11 @@ fn main2() -> Result<(), Box<dyn std::error::Error>> {
}
// set up crosslink error reporting
let diagnostic_count: std::cell::Cell<i32> = Default::default();
let error_entity: std::cell::Cell<Option<String>> = Default::default();
let error_entity_put = |string: String| error_entity.set(Some(string));
let error_entity_print = || {
diagnostic_count.set(diagnostic_count.get() + 1);
if let Some(name) = error_entity.take() {
eprintln!("{}:", name);
}
@ -642,8 +644,12 @@ fn main2() -> Result<(), Box<dyn std::error::Error>> {
);
}
if dry_run {
return Ok(());
{
// Ensure the diagnostic count is not increased after this point.
let exit_code = diagnostic_count.into_inner();
if dry_run {
std::process::exit(exit_code);
}
}
// load tera templates