diff --git a/crates/omnix-ci/src/command/run.rs b/crates/omnix-ci/src/command/run.rs index f1714752..4f437671 100644 --- a/crates/omnix-ci/src/command/run.rs +++ b/crates/omnix-ci/src/command/run.rs @@ -198,7 +198,7 @@ pub async fn check_nix_version(cfg: &OmConfig, nix_info: &NixInfo) -> anyhow::Re let checks = omnix_health .nix_version .check(nix_info, Some(&cfg.flake_url)); - let exit_code = NixHealth::print_report_returning_exit_code(&checks).await?; + let exit_code = NixHealth::print_report_returning_exit_code(&checks, false).await?; if exit_code != 0 { std::process::exit(exit_code); diff --git a/crates/omnix-cli/src/command/health.rs b/crates/omnix-cli/src/command/health.rs index 1b6f27c9..62a4afad 100644 --- a/crates/omnix-cli/src/command/health.rs +++ b/crates/omnix-cli/src/command/health.rs @@ -25,12 +25,8 @@ impl HealthCommand { println!("{}", NixHealth::schema()?); return Ok(()); } - let checks_map = run_all_checks_with(self.flake_url.clone()).await?; - let exit_code = if self.json { - NixHealth::print_json_report_returning_exit_code(&checks_map).await? - } else { - NixHealth::print_report_returning_exit_code(&checks_map).await? - }; + let checks = run_all_checks_with(self.flake_url.clone()).await?; + let exit_code = NixHealth::print_report_returning_exit_code(&checks, self.json).await?; if exit_code != 0 { std::process::exit(exit_code); } diff --git a/crates/omnix-health/src/lib.rs b/crates/omnix-health/src/lib.rs index b335729f..5957257d 100644 --- a/crates/omnix-health/src/lib.rs +++ b/crates/omnix-health/src/lib.rs @@ -85,33 +85,25 @@ impl NixHealth { .collect() } - pub async fn print_json_report_returning_exit_code( + pub async fn print_report_returning_exit_code( checks_map: &HashMap<&'static str, Check>, + json_only: bool, ) -> anyhow::Result { let mut res = AllChecksResult::new(); for check in checks_map.values() { + if !json_only { + check.tracing_log().await?; + } if !check.result.green() { res.register_failure(check.required); }; } let code = res.report(); - println!("{}", serde_json::to_string_pretty(checks_map)?); - Ok(code) - } - pub async fn print_report_returning_exit_code( - checks_map: &HashMap<&'static str, Check>, - ) -> anyhow::Result { - let mut res = AllChecksResult::new(); - for check in checks_map.values() { - check.tracing_log().await?; - if !check.result.green() { - res.register_failure(check.required); - }; + if json_only { + println!("{}", serde_json::to_string_pretty(checks_map)?); } - - let code = res.report(); Ok(code) }