aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
blob: 7cf2f456a90329fb4d1ed1516ff54fc418c36dbf (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
#![recursion_limit = "1024"]

extern crate chrono;
extern crate clap;
extern crate dirs;
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate lazy_static;
extern crate rayon;
extern crate regex;
extern crate reqwest;
extern crate rss;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate serde_yaml;
extern crate toml;

pub mod actions;
pub mod match_handler;
pub mod migration_handler;
pub mod parser;
pub mod structs;
pub mod utils;
pub mod errors {
    error_chain! {}
}

use self::errors::*;
use self::structs::*;

const VERSION: &str = "0.9.0";

fn main() -> Result<()> {
    utils::create_directories().chain_err(|| "unable to create directories")?;
    migration_handler::migrate_old_subscriptions()?;
    let mut state = State::new(VERSION).chain_err(|| "unable to load state")?;
    let config = Config::new()?;
    let mut app = parser::get_app(&VERSION);
    let matches = app.clone().get_matches();
    match_handler::handle_matches(&VERSION, &mut state, &config, &mut app, &matches)?;
    state.save().chain_err(|| "unable to save state")
}