aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-core/src/installer
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-10 15:29:19 +0900
committernsfisis <nsfisis@gmail.com>2026-05-10 15:29:19 +0900
commit46845eff8d1398f35099a0ef914f77bcaf473287 (patch)
tree12c4850f1d2f438d0ba6c363fdc0e5036cd4601d /crates/mozart-core/src/installer
parent212506c364b2342dd9e5fa789e8cff38835dfe52 (diff)
downloadphp-mozart-46845eff8d1398f35099a0ef914f77bcaf473287.tar.gz
php-mozart-46845eff8d1398f35099a0ef914f77bcaf473287.tar.zst
php-mozart-46845eff8d1398f35099a0ef914f77bcaf473287.zip
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<Mutex<Box<dyn IoInterface>>>` 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.
Diffstat (limited to 'crates/mozart-core/src/installer')
-rw-r--r--crates/mozart-core/src/installer/suggested_packages_reporter.rs12
1 files changed, 6 insertions, 6 deletions
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<Suggestion>,
- 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!(
"<info>{} package suggestions were added by new dependencies, use `composer suggest` to see details.</info>",
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}");
}
}