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/suggests.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/mozart/src/commands/suggests.rs') diff --git a/crates/mozart/src/commands/suggests.rs b/crates/mozart/src/commands/suggests.rs index 1643e94..b882f5c 100644 --- a/crates/mozart/src/commands/suggests.rs +++ b/crates/mozart/src/commands/suggests.rs @@ -1,6 +1,6 @@ use clap::Args; use indexmap::IndexSet; -use mozart_core::console; +use mozart_core::console::IoInterface; use mozart_core::installer::{ InstalledRepoLite, MODE_BY_PACKAGE, MODE_BY_SUGGESTION, MODE_LIST, RootInfo, SuggestedPackagesReporter, @@ -37,8 +37,10 @@ pub struct SuggestsArgs { pub async fn execute( args: &SuggestsArgs, cli: &super::Cli, - console: &console::Console, + io: std::sync::Arc>>, ) -> anyhow::Result<()> { + let io_guard = io.lock().unwrap(); + let console = &**io_guard; let working_dir = cli.working_dir()?; let lock_path = working_dir.join("composer.lock"); @@ -314,8 +316,8 @@ mod tests { } } - fn console() -> console::Console { - console::Console::new(0, false, false, true, true) + fn console() -> mozart_core::console::Console { + mozart_core::console::Console::new(0, false, false, true, true) } #[test] -- cgit v1.3.1