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/bump.rs | 41 +++++++++++++------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) (limited to 'crates/mozart/src/commands/bump.rs') diff --git a/crates/mozart/src/commands/bump.rs b/crates/mozart/src/commands/bump.rs index f295cd9..b322dbe 100644 --- a/crates/mozart/src/commands/bump.rs +++ b/crates/mozart/src/commands/bump.rs @@ -1,4 +1,5 @@ use clap::Args; +use mozart_core::console_format; use std::collections::HashMap; use std::path::PathBuf; @@ -51,24 +52,10 @@ pub async fn execute( match root.package_type.as_deref() { Some("project") => {} Some(pkg_type) => { - console.info(&format!( - "{}", - mozart_core::console::warning(&format!( - "Warning: Bumping constraints for a non-project package (type=\"{pkg_type}\"). \ - Libraries should not pin their dependencies." - )) - )); + console.info(&console_format!("Warning: Bumping constraints for a non-project package (type=\"{pkg_type}\"). Libraries should not pin their dependencies.")); } None if !args.dev_only => { - console.info(&format!( - "{}", - mozart_core::console::warning( - "Warning: Bumping constraints for a non-project package. \ - No type was set so it defaults to \"library\". \ - Libraries should not pin their dependencies. \ - Consider using --dev-only or setting the type to \"project\"." - ) - )); + console.info(&console_format!("Warning: Bumping constraints for a non-project package. No type was set so it defaults to \"library\". Libraries should not pin their dependencies. Consider using --dev-only or setting the type to \"project\".")); } None => {} } @@ -161,10 +148,10 @@ pub async fn execute( if total_changes == 0 { println!( "{}", - mozart_core::console::info(&format!( - "No requirements to update in {}.", + console_format!( + "No requirements to update in {}.", composer_json_path.display() - )) + ) ); return Ok(()); } @@ -172,21 +159,21 @@ pub async fn execute( if args.dry_run { println!( "{}", - mozart_core::console::info(&format!( - "{} would be updated with:", + console_format!( + "{} would be updated with:", composer_json_path.display() - )) + ) ); for (name, _old, new) in &require_changes { println!( "{}", - mozart_core::console::info(&format!(" - require.{name}: {new}")) + console_format!(" - require.{name}: {new}") ); } for (name, _old, new) in &require_dev_changes { println!( "{}", - mozart_core::console::info(&format!(" - require-dev.{name}: {new}")) + console_format!(" - require-dev.{name}: {new}") ); } // Return exit code 1 when dry-run detects changes (useful for CI to detect un-bumped constraints) @@ -216,10 +203,10 @@ pub async fn execute( println!( "{}", - mozart_core::console::info(&format!( - "{} has been updated ({total_changes} changes).", + console_format!( + "{} has been updated ({total_changes} changes).", composer_json_path.display() - )) + ) ); Ok(()) -- cgit v1.3.1