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/self_update.rs | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'crates/mozart/src/commands/self_update.rs') diff --git a/crates/mozart/src/commands/self_update.rs b/crates/mozart/src/commands/self_update.rs index d5ddda0..a326914 100644 --- a/crates/mozart/src/commands/self_update.rs +++ b/crates/mozart/src/commands/self_update.rs @@ -1,6 +1,5 @@ use clap::Args; use mozart_core::MOZART_VERSION; -use mozart_core::console_format; use mozart_core::console_writeln; use std::io::Write; use std::path::{Path, PathBuf}; @@ -280,19 +279,14 @@ async fn update( if args.version.is_none() && target_version == current_version { console_writeln!( console, - &console_format!( - "You are already using the latest available Mozart version {current_version} ({channel} channel)." - ), + "You are already using the latest available Mozart version {current_version} ({channel} channel)." ); if args.clean_backups { // Preserve the most recent backup let latest = find_latest_backup(data_dir).ok(); clean_backups(data_dir, latest.as_deref())?; - console_writeln!( - console, - &console_format!("Old backups removed."), - ); + console_writeln!(console, "Old backups removed."); } return Ok(()); @@ -349,9 +343,7 @@ async fn update( console_writeln!( console, - &console_format!( - "Mozart updated successfully from {current_version} to {target_version}" - ), + "Mozart updated successfully from {current_version} to {target_version}" ); console.info(&format!( "Use `mozart self-update --rollback` to return to version {current_version}" @@ -359,10 +351,7 @@ async fn update( if args.clean_backups { clean_backups(data_dir, Some(&backup_path))?; - console_writeln!( - console, - &console_format!("Old backups removed."), - ); + console_writeln!(console, "Old backups removed."); } Ok(()) @@ -393,7 +382,7 @@ fn rollback( console_writeln!( console, - &console_format!("Rollback successful. Restored version {backup_version}"), + "Rollback successful. Restored version {backup_version}", ); let _ = current_exe; // suppress unused warning -- cgit v1.3.1