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/status.rs | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'crates/mozart/src/commands/status.rs') diff --git a/crates/mozart/src/commands/status.rs b/crates/mozart/src/commands/status.rs index 8647078..30d7396 100644 --- a/crates/mozart/src/commands/status.rs +++ b/crates/mozart/src/commands/status.rs @@ -2,7 +2,6 @@ use clap::Args; use indexmap::IndexMap; use mozart_core::composer::{Composer, InstallationSource, LocalPackage}; use mozart_core::console::Console; -use mozart_core::console_format; use mozart_core::console_writeln; use mozart_core::console_writeln_error; use mozart_core::exit_code; @@ -100,7 +99,7 @@ pub async fn execute( } if errors.is_empty() && unpushed_changes.is_empty() && vcs_version_changes.is_empty() { - console_writeln_error!(console, &console_format!("No local changes")); + console_writeln_error!(console, "No local changes"); return Ok(()); } @@ -110,14 +109,14 @@ pub async fn execute( if !errors.is_empty() { console_writeln_error!( console, - &console_format!("You have changes in the following dependencies:") + "You have changes in the following dependencies:" ); for (path, changes) in &errors { if verbose { - console_writeln!(console, &console_format!("{path}:")); - console_writeln!(console, &indent_block(changes)); + console_writeln!(console, "{path}:"); + console_writeln!(console, "{}", &indent_block(changes)); } else { - console_writeln!(console, path); + console_writeln!(console, "{}", path); } } } @@ -125,16 +124,14 @@ pub async fn execute( if !unpushed_changes.is_empty() { console_writeln_error!( console, - &console_format!( - "You have unpushed changes on the current branch in the following dependencies:" - ) + "You have unpushed changes on the current branch in the following dependencies:" ); for (path, changes) in &unpushed_changes { if verbose { - console_writeln!(console, &console_format!("{path}:")); - console_writeln!(console, &indent_block(changes)); + console_writeln!(console, "{path}:"); + console_writeln!(console, "{}", &indent_block(changes)); } else { - console_writeln!(console, path); + console_writeln!(console, "{}", path); } } } @@ -142,9 +139,7 @@ pub async fn execute( if !vcs_version_changes.is_empty() { console_writeln_error!( console, - &console_format!( - "You have version variations in the following dependencies:" - ) + "You have version variations in the following dependencies:" ); for (path, change) in &vcs_version_changes { if verbose { @@ -162,15 +157,13 @@ pub async fn execute( prev.push_str(&format!(" ({})", change.previous.reference)); curr.push_str(&format!(" ({})", change.current.reference)); } - console_writeln!(console, &console_format!("{path}:")); + console_writeln!(console, "{path}:"); console_writeln!( console, - &console_format!( - " From {prev} to {curr}" - ) + " From {prev} to {curr}" ); } else { - console_writeln!(console, path); + console_writeln!(console, "{}", path); } } } -- cgit v1.3.1