From f7a6d2e9c67c1fdf8fc17fa0461a201fd2720537 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Thu, 19 Jan 2023 18:37:42 +0100 Subject: input mostly inplemented, mods missing --- src/main.rs | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 39e46e8..10980fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ -use std::env; +use std::{env, process}; -use modlist::{config::Cfg, input::get_input}; +use modlist::{config::Cfg, input::{get_input, Cmd}, update, download, list, io}; #[tokio::main] async fn main() { @@ -11,10 +11,49 @@ async fn main() { args.pop(); args.reverse(); - match get_input(config, args).await { - Ok(..) => (), + 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::().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")), + } } -- cgit v1.2.3