mirror of https://github.com/astral-sh/uv
Remove `Option<bool>` for `--no-cache` (#3129)
## Summary This was unintended. We ended up reverting `Option<bool>` everywhere, but I missed this once since it's in a separate file. (If you use `Option<bool>`, Clap requires a value, like `--no-cache true`.) ## Test Plan `cargo run pip install flask --no-cache`
This commit is contained in:
parent
25deddd3bf
commit
0ce039d1f9
|
|
@ -14,9 +14,10 @@ pub struct CacheArgs {
|
||||||
long,
|
long,
|
||||||
short,
|
short,
|
||||||
alias = "no-cache-dir",
|
alias = "no-cache-dir",
|
||||||
env = "UV_NO_CACHE"
|
env = "UV_NO_CACHE",
|
||||||
|
value_parser = clap::builder::BoolishValueParser::new(),
|
||||||
)]
|
)]
|
||||||
pub no_cache: Option<bool>,
|
pub no_cache: bool,
|
||||||
|
|
||||||
/// Path to the cache directory.
|
/// Path to the cache directory.
|
||||||
///
|
///
|
||||||
|
|
@ -35,11 +36,8 @@ impl Cache {
|
||||||
/// 4. A `.uv_cache` directory in the current working directory.
|
/// 4. A `.uv_cache` directory in the current working directory.
|
||||||
///
|
///
|
||||||
/// Returns an absolute cache dir.
|
/// Returns an absolute cache dir.
|
||||||
pub fn from_settings(
|
pub fn from_settings(no_cache: bool, cache_dir: Option<PathBuf>) -> Result<Self, io::Error> {
|
||||||
no_cache: Option<bool>,
|
if no_cache {
|
||||||
cache_dir: Option<PathBuf>,
|
|
||||||
) -> Result<Self, io::Error> {
|
|
||||||
if no_cache.unwrap_or(false) {
|
|
||||||
Cache::temp()
|
Cache::temp()
|
||||||
} else if let Some(cache_dir) = cache_dir {
|
} else if let Some(cache_dir) = cache_dir {
|
||||||
Cache::from_path(cache_dir)
|
Cache::from_path(cache_dir)
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ impl GlobalSettings {
|
||||||
#[allow(clippy::struct_excessive_bools)]
|
#[allow(clippy::struct_excessive_bools)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct CacheSettings {
|
pub(crate) struct CacheSettings {
|
||||||
pub(crate) no_cache: Option<bool>,
|
pub(crate) no_cache: bool,
|
||||||
pub(crate) cache_dir: Option<PathBuf>,
|
pub(crate) cache_dir: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,9 +55,10 @@ impl CacheSettings {
|
||||||
/// Resolve the [`CacheSettings`] from the CLI and workspace configuration.
|
/// Resolve the [`CacheSettings`] from the CLI and workspace configuration.
|
||||||
pub(crate) fn resolve(args: CacheArgs, workspace: Option<&Workspace>) -> Self {
|
pub(crate) fn resolve(args: CacheArgs, workspace: Option<&Workspace>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
no_cache: args
|
no_cache: args.no_cache
|
||||||
.no_cache
|
|| workspace
|
||||||
.or(workspace.and_then(|workspace| workspace.options.no_cache)),
|
.and_then(|workspace| workspace.options.no_cache)
|
||||||
|
.unwrap_or(false),
|
||||||
cache_dir: args
|
cache_dir: args
|
||||||
.cache_dir
|
.cache_dir
|
||||||
.or_else(|| workspace.and_then(|workspace| workspace.options.cache_dir.clone())),
|
.or_else(|| workspace.and_then(|workspace| workspace.options.cache_dir.clone())),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue