mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Add a clean
command to clear the cache (#41)
This commit is contained in:
parent
f14b1f0c95
commit
f3015ffc1f
7 changed files with 28 additions and 3 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1670,6 +1670,7 @@ name = "puffin-cli"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cacache",
|
||||
"clap",
|
||||
"colored",
|
||||
"directories",
|
||||
|
|
|
@ -14,6 +14,7 @@ license = "MIT OR Apache-2.0"
|
|||
[workspace.dependencies]
|
||||
anyhow = { version = "1.0.75" }
|
||||
bitflags = { version = "2.4.0" }
|
||||
cacache = { version = "11.7.1", default-features = false, features = ["tokio-runtime"] }
|
||||
clap = { version = "4.4.6" }
|
||||
colored = { version = "2.0.4" }
|
||||
configparser = { version = "3.0.2" }
|
||||
|
|
|
@ -15,6 +15,7 @@ platform-host = { path = "../platform-host" }
|
|||
puffin-resolver = { path = "../puffin-resolver" }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
cacache = { workspace = true }
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
colored = { workspace = true }
|
||||
directories = { workspace = true }
|
||||
|
|
17
crates/puffin-cli/src/commands/clean.rs
Normal file
17
crates/puffin-cli/src/commands/clean.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
use tracing::info;
|
||||
|
||||
use crate::commands::ExitStatus;
|
||||
|
||||
/// Clear the cache.
|
||||
pub(crate) async fn clean(cache: Option<&Path>) -> Result<ExitStatus> {
|
||||
let Some(cache) = cache else {
|
||||
return Err(anyhow::anyhow!("No cache found"));
|
||||
};
|
||||
|
||||
info!("Clearing cache at {}", cache.display());
|
||||
cacache::clear(cache).await?;
|
||||
Ok(ExitStatus::Success)
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
use std::process::ExitCode;
|
||||
|
||||
pub(crate) use clean::clean;
|
||||
pub(crate) use compile::compile;
|
||||
pub(crate) use sync::sync;
|
||||
|
||||
mod clean;
|
||||
mod compile;
|
||||
mod sync;
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ enum Commands {
|
|||
Compile(CompileArgs),
|
||||
/// Sync dependencies from a `requirements.txt` file.
|
||||
Sync(SyncArgs),
|
||||
/// Clear the cache.
|
||||
Clean,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
|
@ -73,6 +75,7 @@ async fn main() -> ExitCode {
|
|||
)
|
||||
.await
|
||||
}
|
||||
Commands::Clean => commands::clean(dirs.as_ref().map(ProjectDirs::cache_dir)).await,
|
||||
};
|
||||
|
||||
match result {
|
||||
|
|
|
@ -16,9 +16,9 @@ puffin-interpreter = { path = "../puffin-interpreter" }
|
|||
wheel-filename = { path = "../wheel-filename" }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
cacache = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
url = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tokio-util = { workspace = true }
|
||||
cacache = { version = "11.7.1", default-features = false, features = ["tokio-runtime"] }
|
||||
tracing = { workspace = true }
|
||||
url = { workspace = true }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue