From 6f3802fd9f39c4e5847d130b4417b5cdfb66972d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 22 Feb 2026 22:53:09 +0900 Subject: 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!("text {name}")`. 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 --- crates/mozart/src/commands/validate.rs | 38 ++++++++++++---------------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'crates/mozart/src/commands/validate.rs') 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!( + "{pkg_name}: composer.json contains invalid JSON" + ) ); 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!("{pkg_name}: {e}")); dep_errors += 1; } for w in &result.warnings { - eprintln!( - "{}", - mozart_core::console::warning(&format!("{pkg_name}: {w}")) - ); + eprintln!("{}", console_format!("{pkg_name}: {w}")); 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!( + "{name} is invalid, the following errors/warnings were found:" + ) ); } 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!("{name} is valid for simple usage with Composer but has") ); 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!("{name} is valid, but with a few warnings") ); 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!("{name} is valid but your composer.lock has some {kind}") ); } else { - println!( - "{}", - mozart_core::console::info(&format!("{name} is valid")) - ); + println!("{}", console_format!("{name} is valid")); } // Collect error and warning message lines -- cgit v1.3.1