aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/commands/licenses.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-09 12:15:21 +0900
committernsfisis <nsfisis@gmail.com>2026-05-09 12:15:53 +0900
commitf18c18cd15f180b5067069ec6f10530515715f3d (patch)
tree85ea3d3f10da9b32359dc3797fc7e6d262ae6752 /crates/mozart/src/commands/licenses.rs
parentf0192390ae1d89981f59395307e885a595f86eef (diff)
downloadphp-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/licenses.rs')
-rw-r--r--crates/mozart/src/commands/licenses.rs72
1 files changed, 27 insertions, 45 deletions
diff --git a/crates/mozart/src/commands/licenses.rs b/crates/mozart/src/commands/licenses.rs
index 468fde7..394cc39 100644
--- a/crates/mozart/src/commands/licenses.rs
+++ b/crates/mozart/src/commands/licenses.rs
@@ -3,7 +3,6 @@ use indexmap::IndexMap;
use mozart_core::composer::Composer;
use mozart_core::console::Console;
use mozart_core::console::hyperlink;
-use mozart_core::console_format;
use mozart_core::console_writeln;
use mozart_core::package_info;
use mozart_core::package_info::PackageUrls;
@@ -273,18 +272,9 @@ fn render_text(
} else {
root_licenses.join(", ")
};
- console_writeln!(
- console,
- &console_format!("Name: <comment>{root_pretty_name}</comment>"),
- );
- console_writeln!(
- console,
- &console_format!("Version: <comment>{root_version}</comment>"),
- );
- console_writeln!(
- console,
- &console_format!("Licenses: <comment>{license_display}</comment>"),
- );
+ console_writeln!(console, "Name: <comment>{root_pretty_name}</comment>");
+ console_writeln!(console, "Version: <comment>{root_version}</comment>");
+ console_writeln!(console, "Licenses: <comment>{license_display}</comment>");
console_writeln!(console, "Dependencies:");
console_writeln!(console, "");
@@ -307,13 +297,11 @@ fn render_text(
console_writeln!(
console,
- &format!(
- "{:<nw$} {:<vw$} Licenses",
- "Name",
- "Version",
- nw = name_width,
- vw = version_width
- ),
+ "{:<nw$} {:<vw$} Licenses",
+ "Name",
+ "Version",
+ nw = name_width,
+ vw = version_width,
);
for entry in entries {
@@ -329,13 +317,11 @@ fn render_text(
};
console_writeln!(
console,
- &format!(
- "{} {:<vw$} {}",
- name_cell,
- entry.version,
- license_str,
- vw = version_width
- ),
+ "{} {:<vw$} {}",
+ name_cell,
+ entry.version,
+ license_str,
+ vw = version_width,
);
}
}
@@ -379,7 +365,7 @@ fn render_json(
let formatter = serde_json::ser::PrettyFormatter::with_indent(b" ");
let mut ser = serde_json::Serializer::with_formatter(buf, formatter);
output.serialize(&mut ser)?;
- console_writeln!(console, &String::from_utf8(ser.into_inner())?,);
+ console_writeln!(console, "{}", &String::from_utf8(ser.into_inner())?);
Ok(())
}
@@ -409,31 +395,27 @@ fn render_summary(entries: &[LicenseEntry], console: &Console) {
let border_col1 = "-".repeat(license_width + 2);
let border_col2 = "-".repeat(count_width + 2);
- console_writeln!(console, &format!(" {} {}", border_col1, border_col2),);
+ console_writeln!(console, " {} {}", border_col1, border_col2);
console_writeln!(
console,
- &format!(
- " {:<lw$} {:<cw$}",
- "License",
- COL2_HEADER,
- lw = license_width,
- cw = count_width
- ),
+ " {:<lw$} {:<cw$}",
+ "License",
+ COL2_HEADER,
+ lw = license_width,
+ cw = count_width,
);
- console_writeln!(console, &format!(" {} {}", border_col1, border_col2),);
+ console_writeln!(console, " {} {}", border_col1, border_col2);
for (license, count) in &counts {
console_writeln!(
console,
- &format!(
- " {:<lw$} {:<cw$}",
- license,
- count,
- lw = license_width,
- cw = count_width
- ),
+ " {:<lw$} {:<cw$}",
+ license,
+ count,
+ lw = license_width,
+ cw = count_width,
);
}
- console_writeln!(console, &format!(" {} {}", border_col1, border_col2),);
+ console_writeln!(console, " {} {}", border_col1, border_col2);
}
/// Mirror of `LicensesCommand::execute`'s `summary` accumulator.