use anyhow::Result;
use clap::Parser;
use kron_lib::*;
use pager::Pager;
#[derive(Parser)]
#[command(about, version, max_term_width = 80)]
struct Cli {
#[arg(short, long, default_value = "ISO8601")]
format: String,
#[arg(short, long)]
readme: bool,
#[arg(name = "ARG")]
args: Vec<String>,
}
fn main() -> Result<()> {
let cli = Cli::parse();
if cli.readme {
Pager::with_pager("bat -pl md").setup();
print!("{}", include_str!("../README.md"));
return Ok(());
}
let fmt = KronFormat::from(&cli.format)?;
let mut timestamps = vec![];
for arg in &cli.args {
timestamps.push(Kron::from(arg)?);
}
if timestamps.is_empty() {
timestamps.push(Kron::now());
}
for timestamp in timestamps {
println!("{}", timestamp.format(&fmt)?);
}
Ok(())
}