summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 10980fb6da67e7815203d61192886ddae4cf8b49 (plain) (blame)
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
use std::{env, process};

use modlist::{config::Cfg, input::{get_input, Cmd}, update, download, list, io};

#[tokio::main]
async fn main() {
    let config = Cfg::init("modlist.toml").unwrap();

    let mut args: Vec<String> = env::args().collect();
    args.reverse();
    args.pop();
    args.reverse();
    
    let input = match get_input(config.clone(), args).await {
        Ok(i) => i,
        Err(e) => {
            println!("{}", e);
            process::exit(1);
        }
    };

    dbg!(&input);

    match input.clone().command.unwrap() {
        Cmd::Mod => {
            Ok(())
        },
        Cmd::List => {
            list(config, input).await
        },
        Cmd::Update => {
            update(config, input).await
        },
        Cmd::Download => {
            download(config, input).await
        },
        Cmd::Io => {
            io(config, input).await
        },
        Cmd::Version => {
            show_version();
            Ok(())
        },
    }.unwrap()
}

fn show_version() {
    match std::env::var("DEV") {
        Ok(dev) => {
            let devint = dev.parse::<i32>().unwrap();
            if devint >= 1 {
                println!("Modlist by FxQnLr v{} (DEV)", env!("CARGO_PKG_VERSION"));
            } else {
                println!("Modlist by FxQnLr v{}", env!("CARGO_PKG_VERSION"));
            }
        },
        Err(..) => println!("Modlist by FxQnLr v{}", env!("CARGO_PKG_VERSION")),
    }
}