mod cli; mod db; mod gui; mod model; mod validation; use anyhow::Result; use clap::Parser; #[derive(Parser)] #[clap()] struct Opt { /// Path of SQLite database in which to store events #[clap(long = "database", default_value = "database.sqlite3")] db_path: String, /// List today’s events as plain text #[clap(long = "list-today")] list_today: bool, /// Start between events as plain text #[clap(long = "start-between")] start_between: Option, } fn main() -> Result<()> { let Opt { db_path, list_today, start_between } = Opt::parse(); let conn = db::init(&db_path)?; if list_today { print!("{}", cli::today(&conn)?); } else { match start_between.and_then(cli::parse_timestamp_range) { Some((from, to)) => print!("{}", cli::start_between(&conn, from, to)?), None => gui::run(conn) } }; Ok(()) }