diff options
author | fx <[email protected]> | 2023-04-23 21:57:09 +0200 |
---|---|---|
committer | fx <[email protected]> | 2023-04-23 21:57:09 +0200 |
commit | 99c84b5a81f395f4f094b157019e84bfc4459df6 (patch) | |
tree | f852fd5cc3b26a004cf7bfab054e86c0d74c4669 /src/main.rs | |
parent | 416f4dc383ff5a1194da3a5532a8e159a4a1dac0 (diff) | |
parent | 3e65975227baa511f570e8223fccda5607cf905e (diff) | |
download | modlist-99c84b5a81f395f4f094b157019e84bfc4459df6.tar modlist-99c84b5a81f395f4f094b157019e84bfc4459df6.tar.gz modlist-99c84b5a81f395f4f094b157019e84bfc4459df6.zip |
Merge pull request 'added config argument, remove devdir' (#2) from dev into cache
Reviewed-on: http://raspberrypi.fritz.box:7920/fx/modlist/pulls/2
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 2006856..957e7c9 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -2,7 +2,7 @@ use clap::{Parser, Subcommand}; | |||
2 | use modlist::{ | 2 | use modlist::{ |
3 | config::Cfg, | 3 | config::Cfg, |
4 | db::{config_get_current_list, lists_get, lists_get_all_ids}, | 4 | db::{config_get_current_list, lists_get, lists_get_all_ids}, |
5 | devdir, download, export, get_current_list, import, list_add, list_change, list_remove, | 5 | download, export, get_current_list, import, list_add, list_change, list_remove, |
6 | list_version, mod_add, mod_remove, update, IDSelector, List, Modloader, | 6 | list_version, mod_add, mod_remove, update, IDSelector, List, Modloader, |
7 | }; | 7 | }; |
8 | 8 | ||
@@ -14,6 +14,10 @@ use modlist::{ | |||
14 | struct Cli { | 14 | struct Cli { |
15 | #[command(subcommand)] | 15 | #[command(subcommand)] |
16 | command: Commands, | 16 | command: Commands, |
17 | |||
18 | /// config file path | ||
19 | #[arg(short, long)] | ||
20 | config: Option<String>, | ||
17 | } | 21 | } |
18 | 22 | ||
19 | #[derive(Subcommand)] | 23 | #[derive(Subcommand)] |
@@ -142,8 +146,8 @@ enum ListCommands { | |||
142 | #[tokio::main] | 146 | #[tokio::main] |
143 | async fn main() { | 147 | async fn main() { |
144 | let cli = Cli::parse(); | 148 | let cli = Cli::parse(); |
145 | 149 | ||
146 | let config = Cfg::init("modlist.toml").unwrap(); | 150 | let config = Cfg::init(cli.config).unwrap(); |
147 | println!("{:?}", config); | 151 | println!("{:?}", config); |
148 | 152 | ||
149 | //TODO setup? maybe setup on install | 153 | //TODO setup? maybe setup on install |
@@ -250,15 +254,14 @@ async fn main() { | |||
250 | Commands::Import { file, download } => { | 254 | Commands::Import { file, download } => { |
251 | let filestr: String = match file { | 255 | let filestr: String = match file { |
252 | Some(args) => args, | 256 | Some(args) => args, |
253 | None => devdir( | 257 | None => |
254 | dirs::home_dir() | 258 | dirs::home_dir() |
255 | .unwrap() | 259 | .unwrap() |
256 | .join("mlexport.toml") | 260 | .join("mlexport.toml") |
257 | .into_os_string() | 261 | .into_os_string() |
258 | .into_string() | 262 | .into_string() |
259 | .unwrap() | 263 | .unwrap() |
260 | .as_str(), | 264 | , |
261 | ), | ||
262 | }; | 265 | }; |
263 | 266 | ||
264 | import(config, filestr, download).await | 267 | import(config, filestr, download).await |