summaryrefslogtreecommitdiff
path: root/src/utils/env.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/env.rs')
-rw-r--r--src/utils/env.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/utils/env.rs b/src/utils/env.rs
index 028995e..5a37365 100644
--- a/src/utils/env.rs
+++ b/src/utils/env.rs
@@ -26,3 +26,24 @@ pub fn current_locales() -> String {
"en".to_string()
}
+
+/// Checks if auto update is enabled based on environment variables.
+///
+/// The function checks the JV_AUTO_UPDATE environment variable and compares
+/// its value (after trimming and converting to lowercase) against known
+/// positive and negative values.
+///
+/// # Returns
+/// `true` if the value matches "yes", "y", or "true"
+/// `false` if the value matches "no", "n", or "false", or if the variable is not set
+pub fn enable_auto_update() -> bool {
+ if let Ok(auto_update) = std::env::var("JV_AUTO_UPDATE") {
+ let normalized = auto_update.trim().to_lowercase();
+ match normalized.as_str() {
+ "yes" | "y" | "true" => return true,
+ "no" | "n" | "false" => return false,
+ _ => {}
+ }
+ }
+ false
+}