summaryrefslogtreecommitdiff
path: root/utils/src/env/editor.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-12 15:54:59 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-12 15:54:59 +0800
commit9d812580557cdc343378816cd65678b8aa75d944 (patch)
treeb1a3397e38d9620a487aed409fc94310f101bc27 /utils/src/env/editor.rs
parent0a95bae451c1847f4f0b9601e60959f4e8e6b669 (diff)
Add lang field to command context and reorganize utils modules
Diffstat (limited to 'utils/src/env/editor.rs')
-rw-r--r--utils/src/env/editor.rs19
1 files changed, 19 insertions, 0 deletions
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()
+}