summaryrefslogtreecommitdiff
path: root/utils/src/env/editor.rs
diff options
context:
space:
mode:
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()
+}