From 501e057189c0291d608a3328a6ad73138264504b Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 18 Apr 2024 18:42:10 -0400 Subject: [PATCH] Remove Option for --no-cache --- crates/uv-cache/src/cli.rs | 12 +++++------- crates/uv/src/settings.rs | 9 +++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/crates/uv-cache/src/cli.rs b/crates/uv-cache/src/cli.rs index 19780139eba7..191118f69cde 100644 --- a/crates/uv-cache/src/cli.rs +++ b/crates/uv-cache/src/cli.rs @@ -14,9 +14,10 @@ pub struct CacheArgs { long, short, alias = "no-cache-dir", - env = "UV_NO_CACHE" + env = "UV_NO_CACHE", + value_parser = clap::builder::BoolishValueParser::new(), )] - pub no_cache: Option, + pub no_cache: bool, /// Path to the cache directory. /// @@ -35,11 +36,8 @@ impl Cache { /// 4. A `.uv_cache` directory in the current working directory. /// /// Returns an absolute cache dir. - pub fn from_settings( - no_cache: Option, - cache_dir: Option, - ) -> Result { - if no_cache.unwrap_or(false) { + pub fn from_settings(no_cache: bool, cache_dir: Option) -> Result { + if no_cache { Cache::temp() } else if let Some(cache_dir) = cache_dir { Cache::from_path(cache_dir) diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index d6685ccd53bd..d1f1de0a0532 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -47,7 +47,7 @@ impl GlobalSettings { #[allow(clippy::struct_excessive_bools)] #[derive(Debug, Clone)] pub(crate) struct CacheSettings { - pub(crate) no_cache: Option, + pub(crate) no_cache: bool, pub(crate) cache_dir: Option, } @@ -55,9 +55,10 @@ impl CacheSettings { /// Resolve the [`CacheSettings`] from the CLI and workspace configuration. pub(crate) fn resolve(args: CacheArgs, workspace: Option<&Workspace>) -> Self { Self { - no_cache: args - .no_cache - .or(workspace.and_then(|workspace| workspace.options.no_cache)), + no_cache: args.no_cache + || workspace + .and_then(|workspace| workspace.options.no_cache) + .unwrap_or(false), cache_dir: args .cache_dir .or_else(|| workspace.and_then(|workspace| workspace.options.cache_dir.clone())),