diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-09 12:15:21 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-09 12:15:53 +0900 |
| commit | f18c18cd15f180b5067069ec6f10530515715f3d (patch) | |
| tree | 85ea3d3f10da9b32359dc3797fc7e6d262ae6752 /crates/mozart/src/commands/dependency.rs | |
| parent | f0192390ae1d89981f59395307e885a595f86eef (diff) | |
| download | php-mozart-f18c18cd15f180b5067069ec6f10530515715f3d.tar.gz php-mozart-f18c18cd15f180b5067069ec6f10530515715f3d.tar.zst php-mozart-f18c18cd15f180b5067069ec6f10530515715f3d.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands/dependency.rs')
| -rw-r--r-- | crates/mozart/src/commands/dependency.rs | 50 |
1 files changed, 19 insertions, 31 deletions
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!( - "<info>{} {} can be installed.</info>", - package, - version.unwrap_or("") - ), + "<info>{} {} can be installed.</info>", + 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!("<info>No relationships found.</info>"), - ); + console_writeln!(console, "<info>No relationships found.</info>"); return; } @@ -683,16 +678,14 @@ pub fn print_table(results: &[DependencyResult], console: &mozart_core::console: } console_writeln!( console, - &format!( - "{:<name_w$} {:<ver_w$} {:<desc_w$} {}", - console_format!("<info>{}</info>", r.package_name), - console_format!("<comment>{}</comment>", r.package_version), - r.link_description, - console_format!("<comment>{}</comment>", r.link_constraint), - name_w = name_w, - ver_w = ver_w, - desc_w = desc_w, - ), + "{:<name_w$} {:<ver_w$} {:<desc_w$} {}", + console_format!("<info>{}</info>", r.package_name), + console_format!("<comment>{}</comment>", r.package_version), + r.link_description, + console_format!("<comment>{}</comment>", 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!("<info>No relationships found.</info>"), - ); + console_writeln!(console, "<info>No relationships found.</info>"); return; } @@ -726,14 +716,12 @@ pub fn print_tree( console_writeln!( console, - &format!( - "{}{:<} {} {} {}", - prefix, - console_format!("<info>{}</info>", r.package_name), - console_format!("<comment>{}</comment>", r.package_version), - r.link_description, - console_format!("<comment>{}</comment>", r.link_constraint), - ), + "{}{:<} {} {} {}", + prefix, + console_format!("<info>{}</info>", r.package_name), + console_format!("<comment>{}</comment>", r.package_version), + r.link_description, + console_format!("<comment>{}</comment>", r.link_constraint), ); if !r.children.is_empty() { |
