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/dump_autoload.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'crates/mozart/src/commands/dump_autoload.rs') diff --git a/crates/mozart/src/commands/dump_autoload.rs b/crates/mozart/src/commands/dump_autoload.rs index f8222bb..fa6c112 100644 --- a/crates/mozart/src/commands/dump_autoload.rs +++ b/crates/mozart/src/commands/dump_autoload.rs @@ -2,6 +2,7 @@ use crate::composer::Composer; use clap::Args; use mozart_core::autoload::AutoloadGeneratorExt; use mozart_core::composer::AutoloadDumpOptions; +use mozart_core::console::IoInterface; use mozart_core::console_writeln; #[derive(Args, Default)] @@ -54,7 +55,7 @@ pub struct DumpAutoloadArgs { pub async fn execute( args: &DumpAutoloadArgs, cli: &super::Cli, - console: &mozart_core::console::Console, + io: std::sync::Arc>>, ) -> anyhow::Result<()> { let composer = Composer::require(cli.working_dir()?)?; @@ -71,7 +72,7 @@ pub async fn execute( { missing = true; console_writeln!( - console, + io, r#"Not all dependencies are installed. Make sure to run a "composer install" to install missing dependencies"#, ); break; @@ -99,13 +100,13 @@ pub async fn execute( if authoritative { console_writeln!( - console, + io, "Generating optimized autoload files (authoritative)", ); } else if optimize { - console_writeln!(console, "Generating optimized autoload files"); + console_writeln!(io, "Generating optimized autoload files"); } else { - console_writeln!(console, "Generating autoload files"); + console_writeln!(io, "Generating autoload files"); } let dev_mode = if args.dev { @@ -147,16 +148,16 @@ pub async fn execute( if authoritative { console_writeln!( - console, + io, "Generated optimized autoload files (authoritative) containing {number_of_classes} classes", ); } else if optimize { console_writeln!( - console, + io, "Generated optimized autoload files containing {number_of_classes} classes", ); } else { - console_writeln!(console, "Generated autoload files"); + console_writeln!(io, "Generated autoload files"); } if missing_dependencies || args.strict_psr && class_map.has_psr_violations() { -- cgit v1.3.1