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/global.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'crates/mozart/src/commands/global.rs') diff --git a/crates/mozart/src/commands/global.rs b/crates/mozart/src/commands/global.rs index 05e8aae..5d5cb81 100644 --- a/crates/mozart/src/commands/global.rs +++ b/crates/mozart/src/commands/global.rs @@ -1,5 +1,5 @@ use clap::Args; -use mozart_core::composer::composer_home; +use mozart_core::{composer::composer_home, console::IoInterface}; #[derive(Args)] pub struct GlobalArgs { @@ -14,7 +14,7 @@ pub struct GlobalArgs { pub async fn execute( args: &GlobalArgs, cli: &super::Cli, - console: &mozart_core::console::Console, + io: std::sync::Arc>>, ) -> anyhow::Result<()> { use clap::Parser as _; use std::fs; @@ -32,7 +32,9 @@ pub async fn execute( fs::create_dir_all(&home)?; - console.info(&format!("Changed current directory to {}", home.display())); + io.lock() + .unwrap() + .info(&format!("Changed current directory to {}", home.display())); // SAFETY: single-threaded at this point; no concurrent env access unsafe { -- cgit v1.3.1