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/diagnose.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/diagnose.rs')
| -rw-r--r-- | crates/mozart/src/commands/diagnose.rs | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/crates/mozart/src/commands/diagnose.rs b/crates/mozart/src/commands/diagnose.rs index fd2297a..af18fdc 100644 --- a/crates/mozart/src/commands/diagnose.rs +++ b/crates/mozart/src/commands/diagnose.rs @@ -58,37 +58,34 @@ fn output_result(label: &str, result: &CheckResult, exit_code: &mut i32, console CheckResult::Ok(detail) => { let ok = "OK".green().bold(); match detail { - Some(d) => console_writeln!( - console, - &format!("{prefix}{ok} {}", format!("({d})").bright_black()) - ), - None => console_writeln!(console, &format!("{prefix}{ok}")), + Some(d) => { + console_writeln!(console, "{prefix}{ok} {}", format!("({d})").bright_black()) + } + None => console_writeln!(console, "{prefix}{ok}"), } } CheckResult::Warning(msgs) => { - console_writeln!(console, &format!("{prefix}{}", "WARNING".yellow().bold())); + console_writeln!(console, "{prefix}{}", "WARNING".yellow().bold()); for msg in msgs { - console_writeln!(console, &format!("{}", msg.yellow())); + console_writeln!(console, "{}", msg.yellow()); } if *exit_code < 1 { *exit_code = 1; } } CheckResult::Fail(msgs) => { - console_writeln!(console, &format!("{prefix}{}", "FAIL".red().bold())); + console_writeln!(console, "{prefix}{}", "FAIL".red().bold()); for msg in msgs { - console_writeln!(console, &format!("{}", msg.red())); + console_writeln!(console, "{}", msg.red()); } *exit_code = 2; } CheckResult::Skip(reason) => { console_writeln!( console, - &format!( - "{prefix}{} {}", - "SKIP".cyan().bold(), - format!("({reason})").bright_black() - ) + "{prefix}{} {}", + "SKIP".cyan().bold(), + format!("({reason})").bright_black(), ); } } @@ -372,7 +369,7 @@ pub async fn execute( // Step 4b (`checkVersion`) is deferred until self-update lands. // Step 5: Mozart version line. - console_writeln!(console, &format!("Mozart version {MOZART_VERSION}")); + console_writeln!(console, "Mozart version {MOZART_VERSION}"); // Step 6: Mozart and its dependencies for vulnerabilities. Deferred — needs // a Mozart Auditor port. @@ -474,13 +471,8 @@ pub async fn execute( { console_writeln!( console, - &format!( - "{}", - format!( - "The COMPOSER_IPRESOLVE env var is set to {val} which may result in network failures below." - ) - .yellow() - ) + "{}", + format!("The COMPOSER_IPRESOLVE env var is set to {val} which may result in network failures below.").yellow(), ); } |
