cron_when/cli/actions/
single.rs1use crate::output;
2use anyhow::Result;
3use tracing::{info, instrument};
4
5#[instrument(level = "info", fields(expression = %expression, verbose = %verbose, color = %color))]
11pub fn execute(expression: &str, verbose: bool, next: Option<u32>, color: bool) -> Result<()> {
12 if let Some(count) = next {
13 info!(iterations = count, "Displaying multiple iterations");
14 output::display_iterations(expression, count)?;
15 } else {
16 info!("Displaying single execution time");
17 output::display_single(expression, verbose, None, None, color)?;
18 }
19 Ok(())
20}
21
22#[cfg(test)]
23mod tests {
24 use super::*;
25
26 #[test]
27 fn test_execute_single_invalid() {
28 let result = execute("invalid", false, None, false);
29 assert!(result.is_err());
30 }
31}