diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-10 15:29:19 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-10 15:29:19 +0900 |
| commit | 46845eff8d1398f35099a0ef914f77bcaf473287 (patch) | |
| tree | 12c4850f1d2f438d0ba6c363fdc0e5036cd4601d /crates/mozart/src/commands/dump_autoload.rs | |
| parent | 212506c364b2342dd9e5fa789e8cff38835dfe52 (diff) | |
| download | php-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/src/commands/dump_autoload.rs')
| -rw-r--r-- | crates/mozart/src/commands/dump_autoload.rs | 17 |
1 files changed, 9 insertions, 8 deletions
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<std::sync::Mutex<Box<dyn IoInterface>>>, ) -> anyhow::Result<()> { let composer = Composer::require(cli.working_dir()?)?; @@ -71,7 +72,7 @@ pub async fn execute( { missing = true; console_writeln!( - console, + io, r#"<warning>Not all dependencies are installed. Make sure to run a "composer install" to install missing dependencies</warning>"#, ); break; @@ -99,13 +100,13 @@ pub async fn execute( if authoritative { console_writeln!( - console, + io, "<info>Generating optimized autoload files (authoritative)</info>", ); } else if optimize { - console_writeln!(console, "<info>Generating optimized autoload files</info>"); + console_writeln!(io, "<info>Generating optimized autoload files</info>"); } else { - console_writeln!(console, "<info>Generating autoload files</info>"); + console_writeln!(io, "<info>Generating autoload files</info>"); } let dev_mode = if args.dev { @@ -147,16 +148,16 @@ pub async fn execute( if authoritative { console_writeln!( - console, + io, "<info>Generated optimized autoload files (authoritative) containing {number_of_classes} classes</info>", ); } else if optimize { console_writeln!( - console, + io, "<info>Generated optimized autoload files containing {number_of_classes} classes</info>", ); } else { - console_writeln!(console, "<info>Generated autoload files</info>"); + console_writeln!(io, "<info>Generated autoload files</info>"); } if missing_dependencies || args.strict_psr && class_map.has_psr_violations() { |
