cron_when/cli/actions/
single.rs

1use crate::output;
2use anyhow::Result;
3use tracing::{info, instrument};
4
5/// Execute a single cron expression
6///
7/// # Errors
8///
9/// Returns an error if cron expression parsing or display fails
10#[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}