summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: ae684772e3b16fe33b5ca6744b6102323b6f1016 (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
mod config;
mod retrieve;

use clap::Parser;
use futures::executor::block_on;

use crate::{config::Config, retrieve::retrieve};

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
    /// Path to the config file. If blank, searches default config locations.
    #[arg(short = 'c', long = "config", default_value = "")]
    config_file: String,
}

fn main() {
    let args = Args::parse();

    let config = match args.config_file.as_str() {
        "" => Config::find_config().unwrap_or_else(||
            panic!("Failed to find config. Paths searched: {:#?}", config::default_config_file_locations())),
        path => Config::parse_config_file_at_path(&path).unwrap_or_else(|err|
            panic!("Failed to parse config at {}. Error: {}", path, err)),
    };

    block_on(async {
        for channel in retrieve(config.urls.iter().map(AsRef::as_ref)).await {
            println!("{:#?}", channel);
        }
    });
}