From 1e43def95472d9c906cff50534b38be2864690f4 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 15 Dec 2025 10:05:21 +0800 Subject: 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 --- src/utils/env.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/utils') 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::() { + 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 -- cgit