aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/commands/clear_cache.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/clear_cache.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/clear_cache.rs')
-rw-r--r--crates/mozart/src/commands/clear_cache.rs33
1 files changed, 11 insertions, 22 deletions
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!(
- "<info>Cache directory does not exist ({key}): {}</info>",
- path.display(),
- ),
+ "<info>Cache directory does not exist ({key}): {}</info>",
+ path.display(),
);
continue;
}
@@ -55,10 +53,8 @@ pub async fn execute(
if !cache.is_enabled() {
console_writeln_error!(
console,
- &console_format!(
- "<info>Cache is not enabled ({key}): {}</info>",
- path.display(),
- ),
+ "<info>Cache is not enabled ({key}): {}</info>",
+ path.display(),
);
continue;
}
@@ -66,10 +62,8 @@ pub async fn execute(
if args.gc {
console_writeln_error!(
console,
- &console_format!(
- "<info>Garbage-collecting cache ({key}): {}</info>",
- path.display(),
- ),
+ "<info>Garbage-collecting cache ({key}): {}</info>",
+ 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!("<info>Clearing cache ({key}): {}</info>", path.display()),
+ "<info>Clearing cache ({key}): {}</info>",
+ path.display(),
);
cache.clear()?;
}
}
if args.gc {
- console_writeln_error!(
- console,
- &console_format!("<info>All caches garbage-collected.</info>"),
- );
+ console_writeln_error!(console, "<info>All caches garbage-collected.</info>");
} else {
- console_writeln_error!(
- console,
- &console_format!("<info>All caches cleared.</info>"),
- );
+ console_writeln_error!(console, "<info>All caches cleared.</info>");
}
Ok(())