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/dependency.rs | 50 ++++++++++++-------------------- 1 file changed, 19 insertions(+), 31 deletions(-) (limited to 'crates/mozart/src/commands/dependency.rs') diff --git a/crates/mozart/src/commands/dependency.rs b/crates/mozart/src/commands/dependency.rs index 8b84fe4..f4e7430 100644 --- a/crates/mozart/src/commands/dependency.rs +++ b/crates/mozart/src/commands/dependency.rs @@ -92,11 +92,9 @@ pub fn do_execute( if inverted { console_writeln!( console, - &console_format!( - "{} {} can be installed.", - package, - version.unwrap_or("") - ), + "{} {} can be installed.", + package, + version.unwrap_or(""), ); return Ok(()); } @@ -648,10 +646,7 @@ fn sample_versions_from_constraint( /// Columns: package name | version | link description | link constraint pub fn print_table(results: &[DependencyResult], console: &mozart_core::console::Console) { if results.is_empty() { - console_writeln!( - console, - &console_format!("No relationships found."), - ); + console_writeln!(console, "No relationships found."); return; } @@ -683,16 +678,14 @@ pub fn print_table(results: &[DependencyResult], console: &mozart_core::console: } console_writeln!( console, - &format!( - "{:{}", r.package_name), - console_format!("{}", r.package_version), - r.link_description, - console_format!("{}", r.link_constraint), - name_w = name_w, - ver_w = ver_w, - desc_w = desc_w, - ), + "{:{}", r.package_name), + console_format!("{}", r.package_version), + r.link_description, + console_format!("{}", r.link_constraint), + name_w = name_w, + ver_w = ver_w, + desc_w = desc_w, ); } } @@ -712,10 +705,7 @@ pub fn print_tree( console: &mozart_core::console::Console, ) { if results.is_empty() && depth == 0 { - console_writeln!( - console, - &console_format!("No relationships found."), - ); + console_writeln!(console, "No relationships found."); return; } @@ -726,14 +716,12 @@ pub fn print_tree( console_writeln!( console, - &format!( - "{}{:<} {} {} {}", - prefix, - console_format!("{}", r.package_name), - console_format!("{}", r.package_version), - r.link_description, - console_format!("{}", r.link_constraint), - ), + "{}{:<} {} {} {}", + prefix, + console_format!("{}", r.package_name), + console_format!("{}", r.package_version), + r.link_description, + console_format!("{}", r.link_constraint), ); if !r.children.is_empty() { -- cgit v1.3.1