aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-06 04:30:02 +0900
committernsfisis <nsfisis@gmail.com>2026-05-06 04:30:02 +0900
commit4a9aff1af9fc74d2928fe54210d6aad5f0afd0b7 (patch)
tree7a439b66d71b3b604b0721c6dc547d00602dd2a5 /crates/mozart
parent2bc47940be9359e34cfe50c64fe76234999bc716 (diff)
downloadphp-mozart-4a9aff1af9fc74d2928fe54210d6aad5f0afd0b7.tar.gz
php-mozart-4a9aff1af9fc74d2928fe54210d6aad5f0afd0b7.tar.zst
php-mozart-4a9aff1af9fc74d2928fe54210d6aad5f0afd0b7.zip
fix(clear-cache): write info messages to stderr to match Composer
Composer's ClearCacheCommand uses $io->writeError() for the per-cache status lines and the final summary; Mozart was writing them to stdout via console.info(). Switch to console_writeln_error\! so the output stream matches Composer.
Diffstat (limited to 'crates/mozart')
-rw-r--r--crates/mozart/src/commands/clear_cache.rs49
1 files changed, 36 insertions, 13 deletions
diff --git a/crates/mozart/src/commands/clear_cache.rs b/crates/mozart/src/commands/clear_cache.rs
index b6ab2f1..6912fbf 100644
--- a/crates/mozart/src/commands/clear_cache.rs
+++ b/crates/mozart/src/commands/clear_cache.rs
@@ -1,7 +1,9 @@
use std::{borrow::Cow, path::Path};
use clap::Args;
-use mozart_core::{composer::Composer, factory::create_config};
+use mozart_core::composer::Composer;
+use mozart_core::factory::create_config;
+use mozart_core::{console_format, console_writeln_error};
use mozart_registry::cache::Cache;
#[derive(Args)]
@@ -39,24 +41,36 @@ pub async fn execute(
let path = Path::new(path);
if !path.exists() {
- console.info(&format!(
- "Cache directory does not exist ({key}): {}",
- path.display()
- ));
+ console_writeln_error!(
+ console,
+ &console_format!(
+ "<info>Cache directory does not exist ({key}): {}</info>",
+ path.display(),
+ ),
+ );
continue;
}
let cache = Cache::new(path.to_owned(), config.cache_read_only);
if !cache.is_enabled() {
- console.info(&format!("Cache is not enabled ({key}): {}", path.display()));
+ console_writeln_error!(
+ console,
+ &console_format!(
+ "<info>Cache is not enabled ({key}): {}</info>",
+ path.display(),
+ ),
+ );
continue;
}
if args.gc {
- console.info(&format!(
- "Garbage-collecting cache ({key}): {}",
- path.display()
- ));
+ console_writeln_error!(
+ console,
+ &console_format!(
+ "<info>Garbage-collecting cache ({key}): {}</info>",
+ path.display(),
+ ),
+ );
match key {
"cache-files-dir" => cache.gc(config.cache_files_ttl, config.cache_files_maxsize)?,
"cache-repo-dir" => cache.gc(config.cache_files_ttl, 1024 * 1024 * 1024 /* 1GB, this should almost never clear anything that is not outdated */)?,
@@ -64,15 +78,24 @@ pub async fn execute(
_ => unreachable!(),
};
} else {
- console.info(&format!("Clearing cache ({key}): {}", path.display()));
+ console_writeln_error!(
+ console,
+ &console_format!("<info>Clearing cache ({key}): {}</info>", path.display()),
+ );
cache.clear()?;
}
}
if args.gc {
- console.info("All caches garbage-collected.");
+ console_writeln_error!(
+ console,
+ &console_format!("<info>All caches garbage-collected.</info>"),
+ );
} else {
- console.info("All caches cleared.");
+ console_writeln_error!(
+ console,
+ &console_format!("<info>All caches cleared.</info>"),
+ );
}
Ok(())