aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
blob: 780f87b274b9ea19727808fcbd42e94cd45e6b64 (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
#![feature(impl_trait_in_bindings)]

extern crate chrono;
extern crate clap;
extern crate dirs;
#[allow(unused_imports)]
#[macro_use]
extern crate failure;
#[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;

mod actions;
mod arg_parser;
mod command_handler;
mod commands;
mod download;
mod migration_handler;
mod parser;
mod playback;
mod structs;
mod utils;

mod errors {
    use failure::Error;
    use std::result;
    pub type Result<T> = result::Result<T, Error>;
}

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

const VERSION: &str = "0.10.3";

fn main() -> Result<()> {
    utils::create_directories()?;
    migration_handler::migrate()?;
    let mut state = State::new(VERSION)?;
    let config = Config::new()?;
    let mut app = parser::get_app(&VERSION);
    let matches = app.clone().get_matches();
    command_handler::handle_matches(&VERSION, &mut state, &config, &mut app, &matches)?;
    state.save()
}