From 4ea6f3933fff4974334e3f9ecb2a423aab43a787 Mon Sep 17 00:00:00 2001 From: sigoden Date: Wed, 10 Jul 2024 18:53:58 +0800 Subject: feat: adjust the way of obtaining function call results (#695) --- src/utils/mod.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/utils/mod.rs') diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 40967ab..35f41a2 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -22,7 +22,7 @@ use anyhow::{Context, Result}; use fancy_regex::Regex; use is_terminal::IsTerminal; use lazy_static::lazy_static; -use std::{env, path::PathBuf}; +use std::{env, path::PathBuf, process}; lazy_static! { pub static ref CODE_BLOCK_RE: Regex = Regex::new(r"(?ms)```\w*(.*)```").unwrap(); @@ -42,14 +42,6 @@ pub fn get_env_name(key: &str) -> String { ) } -pub fn get_env_bool(key: &str) -> bool { - if let Ok(value) = env::var(get_env_name(key)) { - value == "1" || value == "true" - } else { - false - } -} - pub fn tokenize(text: &str) -> Vec<&str> { if text.is_ascii() { text.split_inclusive(|c: char| c.is_ascii_whitespace()) @@ -158,8 +150,9 @@ pub fn dimmed_text(input: &str) -> String { pub fn temp_file(prefix: &str, suffix: &str) -> PathBuf { env::temp_dir().join(format!( - "{}{prefix}{}{suffix}", + "{}-{}{prefix}{}{suffix}", env!("CARGO_CRATE_NAME").to_lowercase(), + process::id(), uuid::Uuid::new_v4() )) } -- cgit v1.2.3