diff --git a/README.md b/README.md index 79b0e1174..3e2d4fbc9 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ If you're running into caching issues, uv includes a few escape hatches: - To force uv to revalidate cached data for all dependencies, run `uv pip install --refresh ...`. - To force uv to revalidate cached data for a specific dependency, run, e.g., `uv pip install --refresh-package flask ...`. - To force uv to ignore existing installed versions, run `uv pip install --reinstall ...`. -- To clear the global cache entirely, run `uv clean`. +- To clear the global cache entirely, run `uv cache clean`. ### Resolution strategy diff --git a/crates/uv/src/main.rs b/crates/uv/src/main.rs index 7ae9e8fad..331ef0c03 100644 --- a/crates/uv/src/main.rs +++ b/crates/uv/src/main.rs @@ -111,11 +111,14 @@ impl From for anstream::ColorChoice { #[allow(clippy::large_enum_variant)] enum Commands { /// Resolve and install Python packages. - Pip(PipArgs), + Pip(PipNamespace), /// Create a virtual environment. #[clap(alias = "virtualenv", alias = "v")] Venv(VenvArgs), + /// Manage the cache. + Cache(CacheNamespace), /// Clear the cache. + #[clap(hide = true)] Clean(CleanArgs), /// Generate shell completion #[clap(alias = "--generate-shell-completion", hide = true)] @@ -123,7 +126,19 @@ enum Commands { } #[derive(Args)] -struct PipArgs { +struct CacheNamespace { + #[clap(subcommand)] + command: CacheCommand, +} + +#[derive(Subcommand)] +enum CacheCommand { + /// Clear the cache. + Clean(CleanArgs), +} + +#[derive(Args)] +struct PipNamespace { #[clap(subcommand)] command: PipCommand, } @@ -804,7 +819,7 @@ async fn run() -> Result { let cache = Cache::try_from(cli.cache_args)?; match cli.command { - Commands::Pip(PipArgs { + Commands::Pip(PipNamespace { command: PipCommand::Compile(args), }) => { args.compat_args.validate()?; @@ -879,7 +894,7 @@ async fn run() -> Result { ) .await } - Commands::Pip(PipArgs { + Commands::Pip(PipNamespace { command: PipCommand::Sync(args), }) => { args.compat_args.validate()?; @@ -922,7 +937,7 @@ async fn run() -> Result { ) .await } - Commands::Pip(PipArgs { + Commands::Pip(PipNamespace { command: PipCommand::Install(args), }) => { let cache = cache.with_refresh(Refresh::from_args(args.refresh, args.refresh_package)); @@ -1000,7 +1015,7 @@ async fn run() -> Result { ) .await } - Commands::Pip(PipArgs { + Commands::Pip(PipNamespace { command: PipCommand::Uninstall(args), }) => { let sources = args @@ -1016,10 +1031,13 @@ async fn run() -> Result { .collect::>(); commands::pip_uninstall(&sources, cache, printer).await } - Commands::Pip(PipArgs { + Commands::Pip(PipNamespace { command: PipCommand::Freeze(args), }) => commands::freeze(&cache, args.strict, printer), - Commands::Clean(args) => commands::clean(&cache, &args.package, printer), + Commands::Cache(CacheNamespace { + command: CacheCommand::Clean(args), + }) + | Commands::Clean(args) => commands::clean(&cache, &args.package, printer), Commands::Venv(args) => { args.compat_args.validate()?;