diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-22 22:53:09 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-22 22:53:22 +0900 |
| commit | 6f3802fd9f39c4e5847d130b4417b5cdfb66972d (patch) | |
| tree | 166cca2cf0645d280bfa376a513a049c70241dea /crates/mozart/src/commands/validate.rs | |
| parent | 1d33728151b282949e7e14646e722d7775de4453 (diff) | |
| download | php-mozart-6f3802fd9f39c4e5847d130b4417b5cdfb66972d.tar.gz php-mozart-6f3802fd9f39c4e5847d130b4417b5cdfb66972d.tar.zst php-mozart-6f3802fd9f39c4e5847d130b4417b5cdfb66972d.zip | |
refactor(console): add console_format! proc macro and migrate all commands
Introduce a Symfony Console-style tag macro that replaces verbose
patterns like `console::info(&format!("text {name}"))` with
`console_format!("<info>text {name}</info>")`. Supports all 6 tag
types (info, comment, error, question, highlight, warning) with
format argument distribution across multiple tagged segments.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands/validate.rs')
| -rw-r--r-- | crates/mozart/src/commands/validate.rs | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/crates/mozart/src/commands/validate.rs b/crates/mozart/src/commands/validate.rs index 2cd460c..614a1cc 100644 --- a/crates/mozart/src/commands/validate.rs +++ b/crates/mozart/src/commands/validate.rs @@ -1,4 +1,5 @@ use clap::Args; +use mozart_core::console_format; use std::path::{Path, PathBuf}; #[derive(Args)] @@ -446,9 +447,9 @@ fn validate_dependencies( format!("{}/{}", vendor_str, pkg_entry.file_name().to_string_lossy()); eprintln!( "{}", - mozart_core::console::warning(&format!( - "{pkg_name}: composer.json contains invalid JSON" - )) + console_format!( + "<warning>{pkg_name}: composer.json contains invalid JSON</warning>" + ) ); continue; }; @@ -463,17 +464,11 @@ fn validate_dependencies( format!("{}/{}", vendor_str, pkg_entry.file_name().to_string_lossy()); for e in &result.errors { - eprintln!( - "{}", - mozart_core::console::error(&format!("{pkg_name}: {e}")) - ); + eprintln!("{}", console_format!("<error>{pkg_name}: {e}</error>")); dep_errors += 1; } for w in &result.warnings { - eprintln!( - "{}", - mozart_core::console::warning(&format!("{pkg_name}: {w}")) - ); + eprintln!("{}", console_format!("<warning>{pkg_name}: {w}</warning>")); dep_warnings += 1; } } @@ -541,16 +536,14 @@ fn output_result( if result.has_errors() { eprintln!( "{}", - mozart_core::console::error(&format!( - "{name} is invalid, the following errors/warnings were found:" - )) + console_format!( + "<error>{name} is invalid, the following errors/warnings were found:</error>" + ) ); } else if result.has_publish_errors() && check_publish { eprintln!( "{}", - mozart_core::console::info(&format!( - "{name} is valid for simple usage with Composer but has" - )) + console_format!("<info>{name} is valid for simple usage with Composer but has</info>") ); eprintln!( "{}", @@ -567,7 +560,7 @@ fn output_result( } else if result.has_warnings() { eprintln!( "{}", - mozart_core::console::info(&format!("{name} is valid, but with a few warnings")) + console_format!("<info>{name} is valid, but with a few warnings</info>") ); eprintln!( "{}", @@ -579,15 +572,10 @@ fn output_result( let kind = if check_lock { "errors" } else { "warnings" }; println!( "{}", - mozart_core::console::info(&format!( - "{name} is valid but your composer.lock has some {kind}" - )) + console_format!("<info>{name} is valid but your composer.lock has some {kind}</info>") ); } else { - println!( - "{}", - mozart_core::console::info(&format!("{name} is valid")) - ); + println!("{}", console_format!("<info>{name} is valid</info>")); } // Collect error and warning message lines |
