diff options
| author | sigoden <sigoden@gmail.com> | 2025-01-17 20:06:28 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-17 20:06:28 +0800 |
| commit | 30dae5c12b81a6f92be138966d8930fa15612cb0 (patch) | |
| tree | ecb641bedbe8798d6b477f1036d714b99f1a8081 /src/utils/mod.rs | |
| parent | 50c60e8097f5148c30295a296063d0fc8391a5f4 (diff) | |
| download | aichat-30dae5c12b81a6f92be138966d8930fa15612cb0.tar.gz | |
feat: support macro (#1087)
Diffstat (limited to 'src/utils/mod.rs')
| -rw-r--r-- | src/utils/mod.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs index c880252..ecc81aa 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -112,16 +112,6 @@ pub fn extract_block(input: &str) -> String { } } -pub fn format_option_value<T>(value: &Option<T>) -> String -where - T: std::fmt::Display, -{ - match value { - Some(value) => value.to_string(), - None => "-".to_string(), - } -} - pub fn convert_option_string(value: &str) -> Option<String> { if value.is_empty() { None @@ -199,6 +189,21 @@ pub fn dimmed_text(input: &str) -> String { nu_ansi_term::Style::new().dimmed().paint(input).to_string() } +pub fn multiline_text(input: &str) -> String { + input + .split('\n') + .enumerate() + .map(|(i, v)| { + if i == 0 { + v.to_string() + } else { + format!(".. {v}") + } + }) + .collect::<Vec<String>>() + .join("\n") +} + pub fn temp_file(prefix: &str, suffix: &str) -> PathBuf { env::temp_dir().join(format!( "{}-{}{prefix}{}{suffix}", |
