diff options
| -rw-r--r-- | utils/src/env.rs | 1 | ||||
| -rw-r--r-- | utils/src/env/helpdoc.rs | 15 | ||||
| -rw-r--r-- | utils/src/input/editor.rs | 8 |
3 files changed, 17 insertions, 7 deletions
diff --git a/utils/src/env.rs b/utils/src/env.rs index 98aaa6b..1c03aa3 100644 --- a/utils/src/env.rs +++ b/utils/src/env.rs @@ -1,3 +1,4 @@ pub mod editor; +pub mod helpdoc; pub mod locales; pub mod pager; diff --git a/utils/src/env/helpdoc.rs b/utils/src/env/helpdoc.rs new file mode 100644 index 0000000..d9bce2c --- /dev/null +++ b/utils/src/env/helpdoc.rs @@ -0,0 +1,15 @@ +/// Gets the default help documentation setting based on environment variables. +/// +/// The function checks the JV_HELPDOC environment variable. +/// If the variable is set to "1", it returns true (enabled). +/// If the variable is set to any other value, it returns false (disabled). +/// If the variable is not set, it returns true (enabled by default). +/// +/// # Returns +/// A boolean indicating whether help documentation is enabled +pub fn get_helpdoc_enabled() -> bool { + match std::env::var("JV_HELPDOC") { + Ok(value) => value == "1", + Err(_) => true, + } +} diff --git a/utils/src/input/editor.rs b/utils/src/input/editor.rs index 34377fd..aa3e1be 100644 --- a/utils/src/input/editor.rs +++ b/utils/src/input/editor.rs @@ -10,13 +10,7 @@ pub async fn input_with_editor( cache_file: impl AsRef<std::path::Path>, comment_char: impl AsRef<str>, ) -> Result<String, std::io::Error> { - input_with_editor_cutsom( - default_text, - cache_file, - comment_char, - get_default_editor().await, - ) - .await + input_with_editor_cutsom(default_text, cache_file, comment_char, get_default_editor()).await } pub async fn input_with_editor_cutsom( |
