summaryrefslogblamecommitdiff
path: root/src/main.rs
blob: 10980fb6da67e7815203d61192886ddae4cf8b49 (plain) (tree)
1
2
3
4
5
6
7
8
                        
 
                                                                                


                 

                                                    




                                                      

                                                             

                              
                             

         





































                                                                                   
 
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")),
    }
}