From 9d812580557cdc343378816cd65678b8aa75d944 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Thu, 12 Mar 2026 15:54:59 +0800 Subject: Add lang field to command context and reorganize utils modules --- utils/src/env/editor.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 utils/src/env/editor.rs (limited to 'utils/src/env/editor.rs') diff --git a/utils/src/env/editor.rs b/utils/src/env/editor.rs new file mode 100644 index 0000000..c7bd446 --- /dev/null +++ b/utils/src/env/editor.rs @@ -0,0 +1,19 @@ +/// 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