From da1a67d4d32b081fee59f30c43695de21225522a Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 27 Feb 2026 06:18:30 +0800 Subject: Add utility functions and macros - Add `current_tempfile_path` function to get temporary file paths - Add `input_with_editor_custom` function that accepts custom editor - Add `string_vec!` macro for creating `Vec` from literals --- utils/src/input.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'utils/src/input.rs') diff --git a/utils/src/input.rs b/utils/src/input.rs index 80ea569..bc67d90 100644 --- a/utils/src/input.rs +++ b/utils/src/input.rs @@ -62,6 +62,21 @@ pub async fn input_with_editor( default_text: impl AsRef, cache_file: impl AsRef, comment_char: impl AsRef, +) -> Result { + input_with_editor_cutsom( + default_text, + cache_file, + comment_char, + get_default_editor().await, + ) + .await +} + +pub async fn input_with_editor_cutsom( + default_text: impl AsRef, + cache_file: impl AsRef, + comment_char: impl AsRef, + editor: String, ) -> Result { let cache_path = cache_file.as_ref(); let default_content = default_text.as_ref(); @@ -70,9 +85,6 @@ pub async fn input_with_editor( // Write default text to cache file fs::write(cache_path, default_content).await?; - // Get editor from environment variable - let editor = get_default_editor().await; - // Open editor with cache file let status = Command::new(editor).arg(cache_path).status().await?; -- cgit