From 78d74b70c7624092553f0ddbe73c2e85be2e4522 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 12 Mar 2026 11:25:44 -0400 Subject: [PATCH] Make uv cache clear an alias of uv cache clean --- crates/uv-cli/src/lib.rs | 1 + crates/uv/tests/it/cache_clean.rs | 32 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index c5c9a8b41e28c..516c9582dd8ef 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -865,6 +865,7 @@ pub struct CacheNamespace { #[derive(Subcommand)] pub enum CacheCommand { /// Clear the cache, removing all entries or those linked to specific packages. + #[command(alias = "clear")] Clean(CleanArgs), /// Prune all unreachable objects from the cache. Prune(PruneArgs), diff --git a/crates/uv/tests/it/cache_clean.rs b/crates/uv/tests/it/cache_clean.rs index 4cef825a09ec5..2ecab759b6f55 100644 --- a/crates/uv/tests/it/cache_clean.rs +++ b/crates/uv/tests/it/cache_clean.rs @@ -36,6 +36,38 @@ fn clean_all() -> Result<()> { Ok(()) } +/// `cache clear` should behave as an alias of `cache clean`. +#[test] +fn clear_all_alias() -> Result<()> { + let context = uv_test::test_context!("3.12"); + + let requirements_txt = context.temp_dir.child("requirements.txt"); + requirements_txt.write_str("typing-extensions\niniconfig")?; + + // Install a requirement, to populate the cache. + context + .pip_sync() + .arg("requirements.txt") + .assert() + .success(); + + let mut command = context.command(); + command.arg("cache").arg("clear").arg("--verbose"); + + uv_snapshot!(context.with_filtered_counts().filters(), command, @" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + DEBUG uv [VERSION] ([COMMIT] DATE) + Clearing cache at: [CACHE_DIR]/ + Removed [N] files ([SIZE]) + "); + + Ok(()) +} + #[tokio::test] async fn clean_force() -> Result<()> { let context = uv_test::test_context!("3.12").with_filtered_counts();