From 46845eff8d1398f35099a0ef914f77bcaf473287 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 10 May 2026 15:29:19 +0900 Subject: refactor(io): introduce IoInterface trait mirroring Composer IOInterface Add an `IoInterface` trait in mozart-core::console that mirrors `\Composer\IO\IOInterface`, implement it for `Console`, and switch commands, the auditor, and the suggested-packages reporter to accept the abstracted IO (typically `Arc>>` at the command boundary, `&dyn IoInterface` deeper down) instead of `&Console`. The console_writeln\!/write\! macros now go through `IoInterface::verbosity()` via the lock so any implementor works. --- crates/mozart/src/commands/audit.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'crates/mozart/src/commands/audit.rs') diff --git a/crates/mozart/src/commands/audit.rs b/crates/mozart/src/commands/audit.rs index eafcba4..9672d57 100644 --- a/crates/mozart/src/commands/audit.rs +++ b/crates/mozart/src/commands/audit.rs @@ -4,6 +4,7 @@ use crate::composer::Composer; use clap::Args; use indexmap::IndexMap; use mozart_core::advisory::{AbandonedHandling, AuditConfig, AuditFormat}; +use mozart_core::console::IoInterface; use mozart_core::repository::advisory::{AuditOptions, Auditor, PackageInfo}; use mozart_core::repository::cache::{Cache, build_cache_config}; use mozart_core::repository::repository::RepositorySet; @@ -38,7 +39,7 @@ pub struct AuditArgs { pub async fn execute( args: &AuditArgs, cli: &super::Cli, - console: &mozart_core::console::Console, + io: std::sync::Arc>>, ) -> anyhow::Result<()> { let working_dir = cli.working_dir()?; @@ -84,7 +85,7 @@ pub async fn execute( let packages = get_packages(&composer, args)?; if packages.is_empty() { - console.info("No packages - skipping audit."); + io.lock().unwrap().info("No packages - skipping audit."); return Ok(()); } @@ -95,7 +96,7 @@ pub async fn execute( // Run audit let exit_code = Auditor::new() .audit( - console, + io.clone(), &repo_set, &packages, &AuditOptions { -- cgit v1.3.1