use crate::output;
use anyhow::Result;
use tracing::{info, instrument};
#[instrument(level = "info", fields(expression = %expression, verbose = %verbose, color = %color))]
pub fn execute(expression: &str, verbose: bool, next: Option<u32>, color: bool) -> Result<()> {
if let Some(count) = next {
info!(iterations = count, "Displaying multiple iterations");
output::display_iterations(expression, count)?;
} else {
info!("Displaying single execution time");
output::display_single(expression, verbose, None, None, color)?;
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_execute_single_invalid() {
let result = execute("invalid", false, None, false);
assert!(result.is_err());
}
}