1use std::path::Path;
2
3use anyhow::Result;
4use mana_core::ops::verify as ops_verify;
5
6use crate::output::Output;
7
8pub fn cmd_verify(mana_dir: &Path, id: &str, out: &Output) -> Result<bool> {
14 let result = ops_verify::run_verify(mana_dir, id)?;
15
16 let Some(result) = result else {
17 out.info(&format!("no verify command set for unit {}", id));
18 return Ok(true);
19 };
20
21 out.info(&format!("Running: {}", result.command));
22 if let Some(secs) = result.timeout_secs {
23 out.info(&format!("Timeout: {}s", secs));
24 }
25
26 if !result.stdout.trim().is_empty() {
27 print!("{}", result.stdout);
28 }
29 if !result.stderr.trim().is_empty() {
30 eprint!("{}", result.stderr);
31 }
32
33 if result.timed_out {
34 out.warn(&format!(
35 "Verify timed out after {}s for unit {}",
36 result.timeout_secs.unwrap_or(0),
37 id
38 ));
39 return Ok(false);
40 }
41
42 if result.passed {
43 out.success(id, "Verify passed");
44 Ok(true)
45 } else {
46 out.error(&format!("Verify failed for unit {}", id));
47 Ok(false)
48 }
49}