From 37e991b7eb1f57090b98ebc02a7fad6a4971e876 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 8 Dec 2025 20:11:22 +0800 Subject: Add jvii binary and set default text editor - Add jvii as a new binary target in Cargo configuration - Set JV_TEXT_EDITOR environment variable to "nano" in CLI scripts - Implement jvii binary with version command support - Add get_default_editor() utility that checks JV_TEXT_EDITOR, EDITOR, then defaults to "jvii" --- src/utils/env.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/utils/env.rs') diff --git a/src/utils/env.rs b/src/utils/env.rs index 5a37365..c96760b 100644 --- a/src/utils/env.rs +++ b/src/utils/env.rs @@ -47,3 +47,23 @@ pub fn enable_auto_update() -> bool { } false } + +/// Gets the default text editor based on environment variables. +/// +/// The function checks the JV_TEXT_EDITOR and EDITOR environment variables +/// and returns their values if they are set. If neither variable is set, +/// it returns "jvii" as the default editor. +/// +/// # Returns +/// A String containing the default text editor +pub async fn get_default_editor() -> String { + if let Ok(editor) = std::env::var("JV_TEXT_EDITOR") { + return editor; + } + + if let Ok(editor) = std::env::var("EDITOR") { + return editor; + } + + "jvii".to_string() +} -- cgit