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/clear_cache.rs | 33 +++++++++++-------------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'crates/mozart/src/commands/clear_cache.rs') diff --git a/crates/mozart/src/commands/clear_cache.rs b/crates/mozart/src/commands/clear_cache.rs index 6912fbf..ee8aad9 100644 --- a/crates/mozart/src/commands/clear_cache.rs +++ b/crates/mozart/src/commands/clear_cache.rs @@ -2,8 +2,8 @@ use std::{borrow::Cow, path::Path}; use clap::Args; use mozart_core::composer::Composer; +use mozart_core::console_writeln_error; use mozart_core::factory::create_config; -use mozart_core::{console_format, console_writeln_error}; use mozart_registry::cache::Cache; #[derive(Args)] @@ -43,10 +43,8 @@ pub async fn execute( if !path.exists() { console_writeln_error!( console, - &console_format!( - "Cache directory does not exist ({key}): {}", - path.display(), - ), + "Cache directory does not exist ({key}): {}", + path.display(), ); continue; } @@ -55,10 +53,8 @@ pub async fn execute( if !cache.is_enabled() { console_writeln_error!( console, - &console_format!( - "Cache is not enabled ({key}): {}", - path.display(), - ), + "Cache is not enabled ({key}): {}", + path.display(), ); continue; } @@ -66,10 +62,8 @@ pub async fn execute( if args.gc { console_writeln_error!( console, - &console_format!( - "Garbage-collecting cache ({key}): {}", - path.display(), - ), + "Garbage-collecting cache ({key}): {}", + path.display(), ); match key { "cache-files-dir" => cache.gc(config.cache_files_ttl, config.cache_files_maxsize)?, @@ -80,22 +74,17 @@ pub async fn execute( } else { console_writeln_error!( console, - &console_format!("Clearing cache ({key}): {}", path.display()), + "Clearing cache ({key}): {}", + path.display(), ); cache.clear()?; } } if args.gc { - console_writeln_error!( - console, - &console_format!("All caches garbage-collected."), - ); + console_writeln_error!(console, "All caches garbage-collected."); } else { - console_writeln_error!( - console, - &console_format!("All caches cleared."), - ); + console_writeln_error!(console, "All caches cleared."); } Ok(()) -- cgit v1.3.1