From 4a9aff1af9fc74d2928fe54210d6aad5f0afd0b7 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 6 May 2026 04:30:02 +0900 Subject: 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. --- crates/mozart/src/commands/clear_cache.rs | 49 +++++++++++++++++++++++-------- 1 file 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!( + "Cache directory does not exist ({key}): {}", + 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!( + "Cache is not enabled ({key}): {}", + path.display(), + ), + ); continue; } if args.gc { - console.info(&format!( - "Garbage-collecting cache ({key}): {}", - path.display() - )); + console_writeln_error!( + console, + &console_format!( + "Garbage-collecting cache ({key}): {}", + 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!("Clearing cache ({key}): {}", path.display()), + ); cache.clear()?; } } if args.gc { - console.info("All caches garbage-collected."); + console_writeln_error!( + console, + &console_format!("All caches garbage-collected."), + ); } else { - console.info("All caches cleared."); + console_writeln_error!( + console, + &console_format!("All caches cleared."), + ); } Ok(()) -- cgit v1.3.1