use crate::language::syntax::ast::{Statement, Value};
use anyhow::Result;
use std::collections::HashMap;
pub fn execute_trigger(
trigger_name: &str,
_body: &[Statement],
_context: &HashMap<String, Value>,
) -> Result<()> {
if trigger_name.is_empty() {
anyhow::bail!("Trigger name cannot be empty");
}
#[cfg(feature = "cli")]
{
if !_body.is_empty() {
eprintln!(
"Executing trigger '{}' with {} statement(s)",
trigger_name,
_body.len()
);
}
}
Ok(())
}
pub fn check_trigger_condition(condition: &Value, context: &HashMap<String, Value>) -> bool {
match condition {
Value::Number(n) => n > &0.0,
Value::String(s) => !s.is_empty(),
Value::Identifier(name) => {
context
.get(name)
.map(|v| matches!(v, Value::Number(n) if n > &0.0))
.unwrap_or(false)
}
_ => false,
}
}