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/reinstall.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'crates/mozart/src/commands/reinstall.rs') diff --git a/crates/mozart/src/commands/reinstall.rs b/crates/mozart/src/commands/reinstall.rs index 52dfd52..fdad41e 100644 --- a/crates/mozart/src/commands/reinstall.rs +++ b/crates/mozart/src/commands/reinstall.rs @@ -2,6 +2,7 @@ use crate::composer::Composer; use clap::Args; use mozart_core::autoload::AutoloadGeneratorExt; use mozart_core::composer::{AutoloadDumpOptions, LocalPackage}; +use mozart_core::console::IoInterface; use mozart_core::console_format; use mozart_core::validation::package_name_to_regexp; @@ -62,7 +63,7 @@ pub struct ReinstallArgs { pub async fn execute( args: &ReinstallArgs, cli: &super::Cli, - console: &mozart_core::console::Console, + io: std::sync::Arc>>, ) -> anyhow::Result<()> { let working_dir = cli.working_dir()?; let composer = Composer::require(&working_dir)?; @@ -101,7 +102,7 @@ pub async fn execute( } } if !matched { - console.error(&console_format!( + io.lock().unwrap().error(&console_format!( "Pattern \"{}\" does not match any currently installed packages.", pattern )); @@ -110,7 +111,7 @@ pub async fn execute( } if packages_to_reinstall.is_empty() { - console.error(&console_format!( + io.lock().unwrap().error(&console_format!( "Found no packages to reinstall, aborting." )); return Err(mozart_core::exit_code::bail_silent( @@ -146,7 +147,7 @@ pub async fn execute( let dist = match package.dist() { Some(d) => d, None => { - console.info(&format!( + io.lock().unwrap().info(&format!( " Warning: {} has no dist information; skipping.", package.pretty_name() )); @@ -154,7 +155,7 @@ pub async fn execute( } }; - console.info(&format!( + io.lock().unwrap().info(&format!( " - Reinstalling {} ({})", package.pretty_name(), package.pretty_version() -- cgit v1.3.1