From a1c7e6908a26e10f6e1f23a51721664b5e2d838d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 17 May 2026 02:53:53 +0900 Subject: chore(style): cargo fmt --- crates/shirabe/src/command/clear_cache_command.rs | 64 +++++++++++++++-------- 1 file changed, 43 insertions(+), 21 deletions(-) (limited to 'crates/shirabe/src/command/clear_cache_command.rs') diff --git a/crates/shirabe/src/command/clear_cache_command.rs b/crates/shirabe/src/command/clear_cache_command.rs index fe2c4dd..06026a4 100644 --- a/crates/shirabe/src/command/clear_cache_command.rs +++ b/crates/shirabe/src/command/clear_cache_command.rs @@ -1,12 +1,12 @@ //! ref: composer/src/Composer/Command/ClearCacheCommand.php -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; -use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use crate::cache::Cache; use crate::command::base_command::BaseCommand; use crate::console::input::input_option::InputOption; use crate::factory::Factory; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; +use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; #[derive(Debug)] pub struct ClearCacheCommand { @@ -19,22 +19,24 @@ impl ClearCacheCommand { .set_name("clear-cache") .set_aliases(vec!["clearcache".to_string(), "cc".to_string()]) .set_description("Clears composer's internal package cache") - .set_definition(vec![ - InputOption::new( - "gc", - None, - InputOption::VALUE_NONE, - "Only run garbage collection, not a full cache clear", - ), - ]) + .set_definition(vec![InputOption::new( + "gc", + None, + InputOption::VALUE_NONE, + "Only run garbage collection, not a full cache clear", + )]) .set_help( "The clear-cache deletes all cached packages from composer's\n\ cache directory.\n\n\ - Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc" + Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc", ); } - pub fn execute(&self, input: &dyn InputInterface, _output: &dyn OutputInterface) -> anyhow::Result { + pub fn execute( + &self, + input: &dyn InputInterface, + _output: &dyn OutputInterface, + ) -> anyhow::Result { let composer = self.inner.try_composer(); let config = if let Some(composer) = composer { composer.get_config() @@ -45,9 +47,18 @@ impl ClearCacheCommand { let io = self.inner.get_io(); let mut cache_paths: IndexMap = IndexMap::new(); - cache_paths.insert("cache-vcs-dir".to_string(), config.get("cache-vcs-dir").to_string()); - cache_paths.insert("cache-repo-dir".to_string(), config.get("cache-repo-dir").to_string()); - cache_paths.insert("cache-files-dir".to_string(), config.get("cache-files-dir").to_string()); + cache_paths.insert( + "cache-vcs-dir".to_string(), + config.get("cache-vcs-dir").to_string(), + ); + cache_paths.insert( + "cache-repo-dir".to_string(), + config.get("cache-repo-dir").to_string(), + ); + cache_paths.insert( + "cache-files-dir".to_string(), + config.get("cache-files-dir").to_string(), + ); cache_paths.insert("cache-dir".to_string(), config.get("cache-dir").to_string()); for (key, cache_path) in &cache_paths { @@ -59,28 +70,39 @@ impl ClearCacheCommand { let cache_path = shirabe_php_shim::realpath(cache_path); if !cache_path.as_ref().map(|s| !s.is_empty()).unwrap_or(false) { let cache_path_display = cache_path.as_deref().unwrap_or(""); - io.write_error(&format!("Cache directory does not exist ({key}): {cache_path_display}")); + io.write_error(&format!( + "Cache directory does not exist ({key}): {cache_path_display}" + )); continue; } let cache_path = cache_path.unwrap(); let mut cache = Cache::new(io, &cache_path); cache.set_read_only(config.get("cache-read-only").as_bool().unwrap_or(false)); if !cache.is_enabled() { - io.write_error(&format!("Cache is not enabled ({key}): {cache_path}")); + io.write_error(&format!( + "Cache is not enabled ({key}): {cache_path}" + )); continue; } if input.get_option("gc").as_bool() { - io.write_error(&format!("Garbage-collecting cache ({key}): {cache_path}")); + io.write_error(&format!( + "Garbage-collecting cache ({key}): {cache_path}" + )); if key == "cache-files-dir" { - cache.gc(config.get("cache-files-ttl"), config.get("cache-files-maxsize"))?; + cache.gc( + config.get("cache-files-ttl"), + config.get("cache-files-maxsize"), + )?; } else if key == "cache-repo-dir" { cache.gc(config.get("cache-ttl"), 1024 * 1024 * 1024)?; } else if key == "cache-vcs-dir" { cache.gc_vcs_cache(config.get("cache-ttl"))?; } } else { - io.write_error(&format!("Clearing cache ({key}): {cache_path}")); + io.write_error(&format!( + "Clearing cache ({key}): {cache_path}" + )); cache.clear()?; } } -- cgit v1.3.1