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/install.rs | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'crates/mozart/src/commands/install.rs') diff --git a/crates/mozart/src/commands/install.rs b/crates/mozart/src/commands/install.rs index 6f8cbe3..4105a7b 100644 --- a/crates/mozart/src/commands/install.rs +++ b/crates/mozart/src/commands/install.rs @@ -1,5 +1,6 @@ use clap::Args; use mozart_core::console; +use mozart_core::console_format; use mozart_registry::downloader; use mozart_registry::installed; use mozart_registry::lockfile; @@ -361,15 +362,15 @@ pub async fn install_from_lock( } else { eprintln!( "{}", - console::info(&format!( - "Package operations: {} install{}, {} update{}, {} removal{}", + console_format!( + "Package operations: {} install{}, {} update{}, {} removal{}", installs.len(), if installs.len() == 1 { "" } else { "s" }, updates.len(), if updates.len() == 1 { "" } else { "s" }, removals.len(), if removals.len() == 1 { "" } else { "s" }, - )) + ) ); } @@ -460,16 +461,15 @@ pub async fn install_from_lock( if config.classmap_authoritative { eprintln!( "{}", - console::info( - "Classmap-authoritative mode: autoloader will only look up classes in the classmap." + console_format!( + "Classmap-authoritative mode: autoloader will only look up classes in the classmap." ) ); } else if config.optimize_autoloader { eprintln!( "{}", - console::info( - "Optimize autoloader: classmap scanning is not yet fully supported. \ - PSR-4/PSR-0 autoloading will still be used." + console_format!( + "Optimize autoloader: classmap scanning is not yet fully supported. PSR-4/PSR-0 autoloading will still be used." ) ); } @@ -524,14 +524,14 @@ pub async fn execute( } if args.dev { - console.info(&console::warning( - "The --dev option is deprecated. Dev packages are installed by default.", + console.info(&console_format!( + "The --dev option is deprecated. Dev packages are installed by default." )); } if args.no_suggest { - console.info(&console::warning( - "The --no-suggest option is deprecated and has no effect.", + console.info(&console_format!( + "The --no-suggest option is deprecated and has no effect." )); } @@ -539,8 +539,8 @@ pub async fn execute( // If no lock file present, fall back to update (matching Composer behavior). let lock_path = working_dir.join("composer.lock"); if !lock_path.exists() { - console.info(&console::warning( - "No composer.lock file present. Updating dependencies to latest instead of installing from lock file.", + console.info(&console_format!( + "No composer.lock file present. Updating dependencies to latest instead of installing from lock file." )); let update_args = super::update::UpdateArgs { packages: vec![], @@ -584,8 +584,8 @@ pub async fn execute( if composer_json_path.exists() { let content = std::fs::read_to_string(&composer_json_path)?; if !lock.is_fresh(&content) { - console.info(&console::warning( - "Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `mozart update`." + console.info(&console_format!( + "Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `mozart update`." )); } } @@ -598,8 +598,8 @@ pub async fn execute( .map(|s| s.eq_ignore_ascii_case("source")) .unwrap_or(false); if prefer_source { - console.info(&console::warning( - "Warning: Source installs are not yet supported. Falling back to dist.", + console.info(&console_format!( + "Warning: Source installs are not yet supported. Falling back to dist." )); } -- cgit v1.3.1