aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 56a499c4ad67cf6da81906ce6a48f683f1be6e87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
mod cli;
mod db;
mod gui;
mod model;
mod validation;

use anyhow::Result;
use structopt::StructOpt;

#[derive(StructOpt)]
#[structopt()]
struct Opt {
    /// Path of SQLite database in which to store events
    #[structopt(long = "database", default_value = "database.sqlite3")]
    db_path: String,

    /// List today’s events as plain text
    #[structopt(long = "list-today")]
    list_today: bool,
}

fn main() -> Result<()> {
    let Opt {
        db_path,
        list_today,
    } = Opt::from_args();
    let conn = db::init(&db_path)?;
    if list_today {
        print!("{}", cli::today(&conn)?);
    } else {
        gui::run(conn);
    }
    Ok(())
}