diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 59d41c5..d177c3e 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -1,13 +1,59 @@ | |||
1 | use modlist::{config::Cfg, input::get_input}; | 1 | use std::{env, process}; |
2 | |||
3 | use modlist::{config::Cfg, input::{get_input, Cmd}, update, download, list, io, modification}; | ||
2 | 4 | ||
3 | #[tokio::main] | 5 | #[tokio::main] |
4 | async fn main() { | 6 | async fn main() { |
5 | let config = Cfg::init("modlist.toml").unwrap(); | 7 | let config = Cfg::init("modlist.toml").unwrap(); |
6 | 8 | ||
7 | match get_input(config).await { | 9 | let mut args: Vec<String> = env::args().collect(); |
8 | Ok(..) => (), | 10 | args.reverse(); |
11 | args.pop(); | ||
12 | args.reverse(); | ||
13 | |||
14 | let input = match get_input(config.clone(), args).await { | ||
15 | Ok(i) => i, | ||
9 | Err(e) => { | 16 | Err(e) => { |
10 | println!("{}", e); | 17 | println!("{}", e); |
18 | process::exit(1); | ||
11 | } | 19 | } |
12 | }; | 20 | }; |
21 | |||
22 | //dbg!(&input); | ||
23 | |||
24 | match input.clone().command.unwrap() { | ||
25 | Cmd::Mod => { | ||
26 | modification(config, input).await | ||
27 | }, | ||
28 | Cmd::List => { | ||
29 | list(config, input).await | ||
30 | }, | ||
31 | Cmd::Update => { | ||
32 | update(config, input).await | ||
33 | }, | ||
34 | Cmd::Download => { | ||
35 | download(config, input).await | ||
36 | }, | ||
37 | Cmd::Io => { | ||
38 | io(config, input).await | ||
39 | }, | ||
40 | Cmd::Version => { | ||
41 | show_version(); | ||
42 | Ok(()) | ||
43 | }, | ||
44 | }.unwrap() | ||
45 | } | ||
46 | |||
47 | fn show_version() { | ||
48 | match std::env::var("DEV") { | ||
49 | Ok(dev) => { | ||
50 | let devint = dev.parse::<i32>().unwrap(); | ||
51 | if devint >= 1 { | ||
52 | println!("Modlist by FxQnLr v{} (DEV)", env!("CARGO_PKG_VERSION")); | ||
53 | } else { | ||
54 | println!("Modlist by FxQnLr v{}", env!("CARGO_PKG_VERSION")); | ||
55 | } | ||
56 | }, | ||
57 | Err(..) => println!("Modlist by FxQnLr v{}", env!("CARGO_PKG_VERSION")), | ||
58 | } | ||
13 | } | 59 | } |