Skip to main content

cli/
references.rs

1use std::path::Path;
2
3use cli_core::CommandError;
4use rpc::references::{Report, check_references};
5use sqlx::types::Uuid;
6
7/// Prints the findings and the coverage; any finding fails the run.
8fn conclude(report: &Report) -> Result<(), CommandError> {
9    report.findings().for_each(|finding| println!("{finding}"));
10    report.summary().iter().for_each(|line| println!("{line}"));
11    match report.findings().next() {
12        None => Ok(()),
13        Some(_) => Err(CommandError::Command(
14            "reference preflight failed".to_string(),
15        )),
16    }
17}
18
19pub async fn run(admin: Uuid, sources: Option<&Path>) -> Result<(), CommandError> {
20    let report = check_references(admin, sources)
21        .await
22        .map_err(|e| CommandError::Command(e.to_string()))?;
23    conclude(&report)
24}
25
26#[cfg(test)]
27mod tests;