summaryrefslogtreecommitdiff
path: root/src/utils/env.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-12-15 10:05:21 +0800
committer魏曹先生 <1992414357@qq.com>2025-12-15 10:05:21 +0800
commit1e43def95472d9c906cff50534b38be2864690f4 (patch)
treee7296275d74efb4e1545d657bc936759291b48fe /src/utils/env.rs
parentb8ac6982f9b81bd686c2c8deb34669e13efd5ba7 (diff)
Update help documentation and move command functionality
- Redesign move command to modify upstream mappings with support for erase operations - Add erased items support to align command and status display - Update help text to reflect new move mapping semantics and add erased item instructions - Add auto-update timeout configuration via JV_OUTDATED_MINUTES environment variable - Improve status display with separate structural and content change modes - Add force flag to hold/throw commands to skip pre-checks - Update completion scripts to include erased items in align command
Diffstat (limited to 'src/utils/env.rs')
-rw-r--r--src/utils/env.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/utils/env.rs b/src/utils/env.rs
index c96760b..e08f117 100644
--- a/src/utils/env.rs
+++ b/src/utils/env.rs
@@ -48,6 +48,31 @@ pub fn enable_auto_update() -> bool {
false
}
+/// Gets the auto update expiration time based on environment variables.
+///
+/// The function checks the JV_OUTDATED_MINUTES environment variable.
+/// Requires JV_AUTO_UPDATE to be enabled.
+/// Next time the `jv` command is used, if the content is outdated, `jv update` will be automatically executed.
+///
+/// # Returns
+/// - When the set number is < 0, timeout-based update is disabled
+/// - When the set number = 0, update runs every time (not recommended)
+/// - When the set number > 0, update according to the specified time
+/// - If not set or conversion error occurs, the default is -1
+pub fn auto_update_outdate() -> i64 {
+ if !enable_auto_update() {
+ return -1;
+ }
+
+ match std::env::var("JV_OUTDATED_MINUTES") {
+ Ok(value) => match value.trim().parse::<i64>() {
+ Ok(num) => num,
+ Err(_) => -1,
+ },
+ Err(_) => -1,
+ }
+}
+
/// Gets the default text editor based on environment variables.
///
/// The function checks the JV_TEXT_EDITOR and EDITOR environment variables