From 7cd15fe67ca0118520dcc4e9e189d513b0375e10 Mon Sep 17 00:00:00 2001 From: Jonas Maier <> Date: Sat, 23 May 2026 23:34:31 +0200 Subject: prompt evaluation in own module --- src/parse/mod.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/parse/mod.rs') diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 5059311..6ce3133 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -551,6 +551,11 @@ impl StringPart { pub fn is_boring(&self) -> bool { matches!(self, StringPart::Boring(..)) } + + pub fn is_command(&self) -> bool { + matches!(self, StringPart::Cmd(..)) + } + pub fn unwrap_boring(self) -> BString { match self { StringPart::Boring(items) => items, @@ -588,6 +593,21 @@ impl ExpString { } Ok(out) } + + pub fn has_commands(&self) -> bool { + self.parts.iter().any(|part| part.is_command()) + } + + /// vars that are directly mentioned in this string interpolation, i.e. does not look into commands + pub fn vars(&self) -> Vec { + self.parts + .iter() + .filter_map(|part| match part { + StringPart::Var(var) => Some(var.name.name.clone()), + _ => None, + }) + .collect() + } } fn is_symbol(x: u8) -> bool { -- cgit v1.2.3