From f18c18cd15f180b5067069ec6f10530515715f3d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 9 May 2026 12:15:21 +0900 Subject: refactor(console): accept format args directly in console_writeln! macros Eliminate the nested &console_format!(...) boilerplate at every call site by teaching console_writeln!, console_write!, console_writeln_error!, and console_write_error! to accept a format literal + variadic args directly, matching the println!/eprintln! ergonomics. Propagate the format string span into generated code so rustc errors point to the right location. Co-Authored-By: Claude Sonnet 4.6 --- crates/mozart/src/commands/bump.rs | 58 +++++++++++--------------------------- 1 file changed, 17 insertions(+), 41 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 a4c71b8..6c53784 100644 --- a/crates/mozart/src/commands/bump.rs +++ b/crates/mozart/src/commands/bump.rs @@ -2,7 +2,6 @@ use clap::Args; use indexmap::IndexMap; use mozart_core::composer::{Composer, LocalRepository}; use mozart_core::console::Console; -use mozart_core::console_format; use mozart_core::{console_writeln, console_writeln_error}; use std::collections::BTreeMap; use std::path::Path; @@ -69,10 +68,8 @@ pub async fn do_bump( if !is_readable(&composer_json_path) { console_writeln_error!( io, - &console_format!( - "{} is not readable.", - composer_json_path.display() - ), + "{} is not readable.", + composer_json_path.display(), ); return Ok(mozart_core::exit_code::GENERAL_ERROR); } @@ -82,10 +79,8 @@ pub async fn do_bump( Err(_) => { console_writeln_error!( io, - &console_format!( - "{} is not readable.", - composer_json_path.display() - ), + "{} is not readable.", + composer_json_path.display(), ); return Ok(mozart_core::exit_code::GENERAL_ERROR); } @@ -94,10 +89,8 @@ pub async fn do_bump( if !is_writable(&composer_json_path) { console_writeln_error!( io, - &console_format!( - "{} is not writable.", - composer_json_path.display() - ), + "{} is not writable.", + composer_json_path.display(), ); return Ok(mozart_core::exit_code::GENERAL_ERROR); } @@ -125,9 +118,7 @@ pub async fn do_bump( if !lock.is_fresh(&contents) { console_writeln_error!( io, - &console_format!( - "The lock file is not up to date with the latest changes in composer.json. Run the appropriate `update` to fix that before you use the `bump` command." - ), + "The lock file is not up to date with the latest changes in composer.json. Run the appropriate `update` to fix that before you use the `bump` command.", ); return Ok(ERROR_LOCK_OUTDATED); } @@ -140,22 +131,16 @@ pub async fn do_bump( if package_type != Some("project") && !dev_only { console_writeln_error!( io, - &console_format!( - "Warning: Bumping dependency constraints is not recommended for libraries as it will narrow down your dependencies and may cause problems for your users." - ), + "Warning: Bumping dependency constraints is not recommended for libraries as it will narrow down your dependencies and may cause problems for your users.", ); if package_type.is_none() { console_writeln_error!( io, - &console_format!( - "If your package is not a library, you can explicitly specify the \"type\" by using \"composer config type project\"." - ), + "If your package is not a library, you can explicitly specify the \"type\" by using \"composer config type project\".", ); console_writeln_error!( io, - &console_format!( - "Alternatively you can use {dev_only_flag_hint} to only bump dependencies within \"require-dev\"." - ), + "Alternatively you can use {dev_only_flag_hint} to only bump dependencies within \"require-dev\".", ); } } @@ -244,35 +229,26 @@ pub async fn do_bump( if dry_run { console_writeln!( io, - &console_format!( - "{} would be updated with:", - composer_json_path.display() - ), + "{} would be updated with:", + composer_json_path.display(), ); for (require_type, packages) in &updates { for (package, version) in packages { - console_writeln!( - io, - &console_format!(" - {require_type}.{package}: {version}"), - ); + console_writeln!(io, " - {require_type}.{package}: {version}"); } } } else { console_writeln!( io, - &console_format!( - "{} has been updated ({change_count} changes).", - composer_json_path.display() - ), + "{} has been updated ({change_count} changes).", + composer_json_path.display(), ); } } else { console_writeln!( io, - &console_format!( - "No requirements to update in {}.", - composer_json_path.display() - ), + "No requirements to update in {}.", + composer_json_path.display(), ); } -- cgit v1.3.1