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. --- .../mozart-core/src/installer/suggested_packages_reporter.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/mozart-core/src/installer') diff --git a/crates/mozart-core/src/installer/suggested_packages_reporter.rs b/crates/mozart-core/src/installer/suggested_packages_reporter.rs index 2a356fc..43ef8c4 100644 --- a/crates/mozart-core/src/installer/suggested_packages_reporter.rs +++ b/crates/mozart-core/src/installer/suggested_packages_reporter.rs @@ -5,7 +5,7 @@ //! Composer's reporter exposes so other entry points (install/update) can //! emit a minimalistic post-install hint with the same code path. -use crate::console::{Console, Verbosity}; +use crate::console::{IoInterface, Verbosity}; use crate::console_format; use crate::installer::installed_repo::InstalledRepoLite; use indexmap::IndexSet; @@ -82,14 +82,14 @@ impl RootInfo { /// install/update one-liner). pub struct SuggestedPackagesReporter<'a> { suggested_packages: Vec, - console: &'a Console, + io: &'a dyn IoInterface, } impl<'a> SuggestedPackagesReporter<'a> { - pub fn new(console: &'a Console) -> Self { + pub fn new(io: &'a dyn IoInterface) -> Self { Self { suggested_packages: Vec::new(), - console, + io, } } @@ -204,7 +204,7 @@ impl<'a> SuggestedPackagesReporter<'a> { ) { let suggestions = self.get_filtered_suggestions(installed_repo, only_dependents_of); if !suggestions.is_empty() { - self.console.write( + self.io.write( &console_format!( "{} package suggestions were added by new dependencies, use `composer suggest` to see details.", suggestions.len() @@ -215,7 +215,7 @@ impl<'a> SuggestedPackagesReporter<'a> { } fn write_line(&self, msg: &str) { - if self.console.verbosity >= Verbosity::Normal { + if self.io.verbosity() >= Verbosity::Normal { println!("{msg}"); } } -- cgit v1.3.1