aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 387dc64e0ad51983321ec2464da067b09e8ab487 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#![allow(unused_must_use)]

use std::default::Default;

mod app;
mod command;
mod habit;
mod theme;
mod utils;
mod views;

use crate::app::App;
use crate::command::{open_command_window, Command};
use crate::habit::{Bit, Count, Habit};
use crate::utils::{load_configuration_file, AppConfig};

use chrono::NaiveDate;
use cursive::theme::{BaseColor, Color};
use cursive::views::NamedView;
use cursive::Cursive;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};

lazy_static! {
    pub static ref CONFIGURATION: AppConfig = load_configuration_file();
}

fn main() {
    let mut s = Cursive::crossterm().unwrap();

    // let mut gymming = Count::new("gym", 5);
    // gymming.insert_entry(NaiveDate::from_ymd(2020, 5, 11), 7);
    // gymming.insert_entry(NaiveDate::from_ymd(2020, 5, 12), 8);
    // gymming.insert_entry(NaiveDate::from_ymd(2020, 5, 13), 9);
    // gymming.insert_entry(NaiveDate::from_ymd(2020, 5, 14), 10);
    // gymming.insert_entry(NaiveDate::from_ymd(2020, 5, 15), 11);

    // let mut reading = Bit::new("read");
    // reading.insert_entry(NaiveDate::from_ymd(2020, 5, 11), true.into());
    // reading.insert_entry(NaiveDate::from_ymd(2020, 5, 12), false.into());
    // reading.insert_entry(NaiveDate::from_ymd(2020, 5, 13), true.into());
    // reading.insert_entry(NaiveDate::from_ymd(2020, 5, 14), false.into());
    // reading.insert_entry(NaiveDate::from_ymd(2020, 5, 15), true.into());

    // let mut walking = Bit::new("walk");
    // walking.insert_entry(NaiveDate::from_ymd(2020, 5, 11), true.into());
    // walking.insert_entry(NaiveDate::from_ymd(2020, 5, 12), false.into());
    // walking.insert_entry(NaiveDate::from_ymd(2020, 5, 13), true.into());
    // walking.insert_entry(NaiveDate::from_ymd(2020, 5, 14), false.into());
    // walking.insert_entry(NaiveDate::from_ymd(2020, 5, 15), true.into());

    // app.add_habit(Box::new(gymming));
    // app.add_habit(Box::new(reading));
    // app.add_habit(Box::new(walking));

    let app = App::load_state();
    s.add_layer(NamedView::new("Main", app));
    s.add_global_callback(':', |s| open_command_window(s));

    s.set_theme(theme::theme_gen());
    s.run();
}