diff --git a/src/download.rs b/src/download.rs index 29bd7ca..e3121fd 100644 --- a/src/download.rs +++ b/src/download.rs @@ -178,6 +178,10 @@ fn use_from_cache(opts: &DownloadOpts, file_name: &PathBuf) -> Result { match opts.refresh { RefreshCondition::Always => Ok(false), RefreshCondition::Never => Ok(file_name.exists()), + RefreshCondition::Ask => { + let name = file_name.as_os_str().to_string_lossy(); + Ok(dialoguer::Confirm::new().with_prompt(format!("Refresh this mod archive? ({name})")).interact()?) + } RefreshCondition::Duration(duration) => { let metadata = match std::fs::metadata(file_name) { Err(error) if error.kind() == ErrorKind::NotFound => return Ok(false), diff --git a/src/module/refresh.rs b/src/module/refresh.rs index f218441..dd9a46a 100644 --- a/src/module/refresh.rs +++ b/src/module/refresh.rs @@ -23,6 +23,7 @@ pub enum RefreshCondition { /// - 1day /// - 30min Duration(Duration), + Ask, } serde_with::serde_conv!( @@ -31,6 +32,7 @@ serde_with::serde_conv!( |condition: &RefreshCondition| match condition { RefreshCondition::Never => "never".to_string(), RefreshCondition::Always => "always".to_string(), + RefreshCondition::Ask => "ask".to_string(), RefreshCondition::Duration(duration) => humantime::format_duration(*duration).to_string(), }, |value: String| RefreshCondition::from_str(&value) @@ -43,6 +45,7 @@ impl FromStr for RefreshCondition { return match s { "never" => Ok(RefreshCondition::Never), "always" => Ok(RefreshCondition::Always), + "ask" => Ok(RefreshCondition::Ask), value => match parse_duration(value) { Ok(result) => Ok(RefreshCondition::Duration(result)), Err(error) => Err(ParseRefreshConditionError(error.to_string()))