diff options
author | fxqnlr <[email protected]> | 2024-09-04 13:48:32 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2024-09-04 13:48:32 +0200 |
commit | 7a85cf311c85ab45c75098dae58b5ebf5fef60bc (patch) | |
tree | 8f65f35da12add062df7fdf6d63d47c664542261 | |
parent | 638dc58e86ba3bbe31d50e72788c9681d414e0ae (diff) | |
download | modlist-7a85cf311c85ab45c75098dae58b5ebf5fef60bc.tar modlist-7a85cf311c85ab45c75098dae58b5ebf5fef60bc.tar.gz modlist-7a85cf311c85ab45c75098dae58b5ebf5fef60bc.zip |
add config crate, slight cleanup
-rw-r--r-- | Cargo.lock | 376 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/config.rs | 103 |
3 files changed, 411 insertions, 69 deletions
@@ -87,6 +87,17 @@ dependencies = [ | |||
87 | ] | 87 | ] |
88 | 88 | ||
89 | [[package]] | 89 | [[package]] |
90 | name = "async-trait" | ||
91 | version = "0.1.82" | ||
92 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
93 | checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" | ||
94 | dependencies = [ | ||
95 | "proc-macro2", | ||
96 | "quote", | ||
97 | "syn", | ||
98 | ] | ||
99 | |||
100 | [[package]] | ||
90 | name = "autocfg" | 101 | name = "autocfg" |
91 | version = "1.1.0" | 102 | version = "1.1.0" |
92 | source = "registry+https://github.com/rust-lang/crates.io-index" | 103 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -124,6 +135,18 @@ name = "bitflags" | |||
124 | version = "2.3.1" | 135 | version = "2.3.1" |
125 | source = "registry+https://github.com/rust-lang/crates.io-index" | 136 | source = "registry+https://github.com/rust-lang/crates.io-index" |
126 | checksum = "6776fc96284a0bb647b615056fc496d1fe1644a7ab01829818a6d91cae888b84" | 137 | checksum = "6776fc96284a0bb647b615056fc496d1fe1644a7ab01829818a6d91cae888b84" |
138 | dependencies = [ | ||
139 | "serde", | ||
140 | ] | ||
141 | |||
142 | [[package]] | ||
143 | name = "block-buffer" | ||
144 | version = "0.10.4" | ||
145 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
146 | checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" | ||
147 | dependencies = [ | ||
148 | "generic-array", | ||
149 | ] | ||
127 | 150 | ||
128 | [[package]] | 151 | [[package]] |
129 | name = "bumpalo" | 152 | name = "bumpalo" |
@@ -222,6 +245,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
222 | checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" | 245 | checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" |
223 | 246 | ||
224 | [[package]] | 247 | [[package]] |
248 | name = "config" | ||
249 | version = "0.14.0" | ||
250 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
251 | checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be" | ||
252 | dependencies = [ | ||
253 | "async-trait", | ||
254 | "convert_case", | ||
255 | "json5", | ||
256 | "lazy_static", | ||
257 | "nom", | ||
258 | "pathdiff", | ||
259 | "ron", | ||
260 | "rust-ini", | ||
261 | "serde", | ||
262 | "serde_json", | ||
263 | "toml 0.8.19", | ||
264 | "yaml-rust", | ||
265 | ] | ||
266 | |||
267 | [[package]] | ||
225 | name = "console" | 268 | name = "console" |
226 | version = "0.15.7" | 269 | version = "0.15.7" |
227 | source = "registry+https://github.com/rust-lang/crates.io-index" | 270 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -235,6 +278,35 @@ dependencies = [ | |||
235 | ] | 278 | ] |
236 | 279 | ||
237 | [[package]] | 280 | [[package]] |
281 | name = "const-random" | ||
282 | version = "0.1.18" | ||
283 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
284 | checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" | ||
285 | dependencies = [ | ||
286 | "const-random-macro", | ||
287 | ] | ||
288 | |||
289 | [[package]] | ||
290 | name = "const-random-macro" | ||
291 | version = "0.1.16" | ||
292 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
293 | checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" | ||
294 | dependencies = [ | ||
295 | "getrandom", | ||
296 | "once_cell", | ||
297 | "tiny-keccak", | ||
298 | ] | ||
299 | |||
300 | [[package]] | ||
301 | name = "convert_case" | ||
302 | version = "0.6.0" | ||
303 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
304 | checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" | ||
305 | dependencies = [ | ||
306 | "unicode-segmentation", | ||
307 | ] | ||
308 | |||
309 | [[package]] | ||
238 | name = "core-foundation" | 310 | name = "core-foundation" |
239 | version = "0.9.3" | 311 | version = "0.9.3" |
240 | source = "registry+https://github.com/rust-lang/crates.io-index" | 312 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -251,6 +323,41 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
251 | checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" | 323 | checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" |
252 | 324 | ||
253 | [[package]] | 325 | [[package]] |
326 | name = "cpufeatures" | ||
327 | version = "0.2.9" | ||
328 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
329 | checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" | ||
330 | dependencies = [ | ||
331 | "libc", | ||
332 | ] | ||
333 | |||
334 | [[package]] | ||
335 | name = "crunchy" | ||
336 | version = "0.2.2" | ||
337 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
338 | checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" | ||
339 | |||
340 | [[package]] | ||
341 | name = "crypto-common" | ||
342 | version = "0.1.6" | ||
343 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
344 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" | ||
345 | dependencies = [ | ||
346 | "generic-array", | ||
347 | "typenum", | ||
348 | ] | ||
349 | |||
350 | [[package]] | ||
351 | name = "digest" | ||
352 | version = "0.10.7" | ||
353 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
354 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" | ||
355 | dependencies = [ | ||
356 | "block-buffer", | ||
357 | "crypto-common", | ||
358 | ] | ||
359 | |||
360 | [[package]] | ||
254 | name = "dirs" | 361 | name = "dirs" |
255 | version = "5.0.1" | 362 | version = "5.0.1" |
256 | source = "registry+https://github.com/rust-lang/crates.io-index" | 363 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -272,6 +379,15 @@ dependencies = [ | |||
272 | ] | 379 | ] |
273 | 380 | ||
274 | [[package]] | 381 | [[package]] |
382 | name = "dlv-list" | ||
383 | version = "0.5.2" | ||
384 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
385 | checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" | ||
386 | dependencies = [ | ||
387 | "const-random", | ||
388 | ] | ||
389 | |||
390 | [[package]] | ||
275 | name = "encode_unicode" | 391 | name = "encode_unicode" |
276 | version = "0.3.6" | 392 | version = "0.3.6" |
277 | source = "registry+https://github.com/rust-lang/crates.io-index" | 393 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -287,6 +403,12 @@ dependencies = [ | |||
287 | ] | 403 | ] |
288 | 404 | ||
289 | [[package]] | 405 | [[package]] |
406 | name = "equivalent" | ||
407 | version = "1.0.1" | ||
408 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
409 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" | ||
410 | |||
411 | [[package]] | ||
290 | name = "errno" | 412 | name = "errno" |
291 | version = "0.3.1" | 413 | version = "0.3.1" |
292 | source = "registry+https://github.com/rust-lang/crates.io-index" | 414 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -430,6 +552,16 @@ dependencies = [ | |||
430 | ] | 552 | ] |
431 | 553 | ||
432 | [[package]] | 554 | [[package]] |
555 | name = "generic-array" | ||
556 | version = "0.14.7" | ||
557 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
558 | checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" | ||
559 | dependencies = [ | ||
560 | "typenum", | ||
561 | "version_check", | ||
562 | ] | ||
563 | |||
564 | [[package]] | ||
433 | name = "getrandom" | 565 | name = "getrandom" |
434 | version = "0.2.9" | 566 | version = "0.2.9" |
435 | source = "registry+https://github.com/rust-lang/crates.io-index" | 567 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -458,7 +590,7 @@ dependencies = [ | |||
458 | "futures-sink", | 590 | "futures-sink", |
459 | "futures-util", | 591 | "futures-util", |
460 | "http", | 592 | "http", |
461 | "indexmap", | 593 | "indexmap 1.9.3", |
462 | "slab", | 594 | "slab", |
463 | "tokio", | 595 | "tokio", |
464 | "tokio-util", | 596 | "tokio-util", |
@@ -481,6 +613,12 @@ dependencies = [ | |||
481 | ] | 613 | ] |
482 | 614 | ||
483 | [[package]] | 615 | [[package]] |
616 | name = "hashbrown" | ||
617 | version = "0.14.5" | ||
618 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
619 | checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" | ||
620 | |||
621 | [[package]] | ||
484 | name = "hashlink" | 622 | name = "hashlink" |
485 | version = "0.8.2" | 623 | version = "0.8.2" |
486 | source = "registry+https://github.com/rust-lang/crates.io-index" | 624 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -625,6 +763,16 @@ dependencies = [ | |||
625 | ] | 763 | ] |
626 | 764 | ||
627 | [[package]] | 765 | [[package]] |
766 | name = "indexmap" | ||
767 | version = "2.5.0" | ||
768 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
769 | checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" | ||
770 | dependencies = [ | ||
771 | "equivalent", | ||
772 | "hashbrown 0.14.5", | ||
773 | ] | ||
774 | |||
775 | [[package]] | ||
628 | name = "indicatif" | 776 | name = "indicatif" |
629 | version = "0.17.3" | 777 | version = "0.17.3" |
630 | source = "registry+https://github.com/rust-lang/crates.io-index" | 778 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -690,6 +838,17 @@ dependencies = [ | |||
690 | ] | 838 | ] |
691 | 839 | ||
692 | [[package]] | 840 | [[package]] |
841 | name = "json5" | ||
842 | version = "0.4.1" | ||
843 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
844 | checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" | ||
845 | dependencies = [ | ||
846 | "pest", | ||
847 | "pest_derive", | ||
848 | "serde", | ||
849 | ] | ||
850 | |||
851 | [[package]] | ||
693 | name = "lazy_static" | 852 | name = "lazy_static" |
694 | version = "1.4.0" | 853 | version = "1.4.0" |
695 | source = "registry+https://github.com/rust-lang/crates.io-index" | 854 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -713,6 +872,12 @@ dependencies = [ | |||
713 | ] | 872 | ] |
714 | 873 | ||
715 | [[package]] | 874 | [[package]] |
875 | name = "linked-hash-map" | ||
876 | version = "0.5.6" | ||
877 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
878 | checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" | ||
879 | |||
880 | [[package]] | ||
716 | name = "linux-raw-sys" | 881 | name = "linux-raw-sys" |
717 | version = "0.3.8" | 882 | version = "0.3.8" |
718 | source = "registry+https://github.com/rust-lang/crates.io-index" | 883 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -750,6 +915,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
750 | checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" | 915 | checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" |
751 | 916 | ||
752 | [[package]] | 917 | [[package]] |
918 | name = "minimal-lexical" | ||
919 | version = "0.2.1" | ||
920 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
921 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" | ||
922 | |||
923 | [[package]] | ||
753 | name = "miniz_oxide" | 924 | name = "miniz_oxide" |
754 | version = "0.6.2" | 925 | version = "0.6.2" |
755 | source = "registry+https://github.com/rust-lang/crates.io-index" | 926 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -777,6 +948,7 @@ dependencies = [ | |||
777 | "chrono", | 948 | "chrono", |
778 | "clap", | 949 | "clap", |
779 | "clap_complete", | 950 | "clap_complete", |
951 | "config", | ||
780 | "dirs", | 952 | "dirs", |
781 | "error-chain", | 953 | "error-chain", |
782 | "futures-util", | 954 | "futures-util", |
@@ -786,7 +958,7 @@ dependencies = [ | |||
786 | "serde", | 958 | "serde", |
787 | "serde_json", | 959 | "serde_json", |
788 | "tokio", | 960 | "tokio", |
789 | "toml", | 961 | "toml 0.7.4", |
790 | ] | 962 | ] |
791 | 963 | ||
792 | [[package]] | 964 | [[package]] |
@@ -808,6 +980,16 @@ dependencies = [ | |||
808 | ] | 980 | ] |
809 | 981 | ||
810 | [[package]] | 982 | [[package]] |
983 | name = "nom" | ||
984 | version = "7.1.3" | ||
985 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
986 | checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" | ||
987 | dependencies = [ | ||
988 | "memchr", | ||
989 | "minimal-lexical", | ||
990 | ] | ||
991 | |||
992 | [[package]] | ||
811 | name = "num-integer" | 993 | name = "num-integer" |
812 | version = "0.1.45" | 994 | version = "0.1.45" |
813 | source = "registry+https://github.com/rust-lang/crates.io-index" | 995 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -908,6 +1090,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
908 | checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" | 1090 | checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" |
909 | 1091 | ||
910 | [[package]] | 1092 | [[package]] |
1093 | name = "ordered-multimap" | ||
1094 | version = "0.6.0" | ||
1095 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1096 | checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e" | ||
1097 | dependencies = [ | ||
1098 | "dlv-list", | ||
1099 | "hashbrown 0.13.2", | ||
1100 | ] | ||
1101 | |||
1102 | [[package]] | ||
911 | name = "parking_lot" | 1103 | name = "parking_lot" |
912 | version = "0.12.1" | 1104 | version = "0.12.1" |
913 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1105 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -931,12 +1123,63 @@ dependencies = [ | |||
931 | ] | 1123 | ] |
932 | 1124 | ||
933 | [[package]] | 1125 | [[package]] |
1126 | name = "pathdiff" | ||
1127 | version = "0.2.1" | ||
1128 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1129 | checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" | ||
1130 | |||
1131 | [[package]] | ||
934 | name = "percent-encoding" | 1132 | name = "percent-encoding" |
935 | version = "2.2.0" | 1133 | version = "2.2.0" |
936 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1134 | source = "registry+https://github.com/rust-lang/crates.io-index" |
937 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" | 1135 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" |
938 | 1136 | ||
939 | [[package]] | 1137 | [[package]] |
1138 | name = "pest" | ||
1139 | version = "2.7.11" | ||
1140 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1141 | checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" | ||
1142 | dependencies = [ | ||
1143 | "memchr", | ||
1144 | "thiserror", | ||
1145 | "ucd-trie", | ||
1146 | ] | ||
1147 | |||
1148 | [[package]] | ||
1149 | name = "pest_derive" | ||
1150 | version = "2.7.11" | ||
1151 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1152 | checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" | ||
1153 | dependencies = [ | ||
1154 | "pest", | ||
1155 | "pest_generator", | ||
1156 | ] | ||
1157 | |||
1158 | [[package]] | ||
1159 | name = "pest_generator" | ||
1160 | version = "2.7.11" | ||
1161 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1162 | checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" | ||
1163 | dependencies = [ | ||
1164 | "pest", | ||
1165 | "pest_meta", | ||
1166 | "proc-macro2", | ||
1167 | "quote", | ||
1168 | "syn", | ||
1169 | ] | ||
1170 | |||
1171 | [[package]] | ||
1172 | name = "pest_meta" | ||
1173 | version = "2.7.11" | ||
1174 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1175 | checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" | ||
1176 | dependencies = [ | ||
1177 | "once_cell", | ||
1178 | "pest", | ||
1179 | "sha2", | ||
1180 | ] | ||
1181 | |||
1182 | [[package]] | ||
940 | name = "pin-project-lite" | 1183 | name = "pin-project-lite" |
941 | version = "0.2.9" | 1184 | version = "0.2.9" |
942 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1185 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -971,18 +1214,18 @@ checksum = "dc59d1bcc64fc5d021d67521f818db868368028108d37f0e98d74e33f68297b5" | |||
971 | 1214 | ||
972 | [[package]] | 1215 | [[package]] |
973 | name = "proc-macro2" | 1216 | name = "proc-macro2" |
974 | version = "1.0.59" | 1217 | version = "1.0.86" |
975 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1218 | source = "registry+https://github.com/rust-lang/crates.io-index" |
976 | checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" | 1219 | checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" |
977 | dependencies = [ | 1220 | dependencies = [ |
978 | "unicode-ident", | 1221 | "unicode-ident", |
979 | ] | 1222 | ] |
980 | 1223 | ||
981 | [[package]] | 1224 | [[package]] |
982 | name = "quote" | 1225 | name = "quote" |
983 | version = "1.0.28" | 1226 | version = "1.0.37" |
984 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1227 | source = "registry+https://github.com/rust-lang/crates.io-index" |
985 | checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" | 1228 | checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" |
986 | dependencies = [ | 1229 | dependencies = [ |
987 | "proc-macro2", | 1230 | "proc-macro2", |
988 | ] | 1231 | ] |
@@ -1056,6 +1299,18 @@ dependencies = [ | |||
1056 | ] | 1299 | ] |
1057 | 1300 | ||
1058 | [[package]] | 1301 | [[package]] |
1302 | name = "ron" | ||
1303 | version = "0.8.1" | ||
1304 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1305 | checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" | ||
1306 | dependencies = [ | ||
1307 | "base64", | ||
1308 | "bitflags 2.3.1", | ||
1309 | "serde", | ||
1310 | "serde_derive", | ||
1311 | ] | ||
1312 | |||
1313 | [[package]] | ||
1059 | name = "rusqlite" | 1314 | name = "rusqlite" |
1060 | version = "0.29.0" | 1315 | version = "0.29.0" |
1061 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1316 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1070,6 +1325,16 @@ dependencies = [ | |||
1070 | ] | 1325 | ] |
1071 | 1326 | ||
1072 | [[package]] | 1327 | [[package]] |
1328 | name = "rust-ini" | ||
1329 | version = "0.19.0" | ||
1330 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1331 | checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091" | ||
1332 | dependencies = [ | ||
1333 | "cfg-if", | ||
1334 | "ordered-multimap", | ||
1335 | ] | ||
1336 | |||
1337 | [[package]] | ||
1073 | name = "rustc-demangle" | 1338 | name = "rustc-demangle" |
1074 | version = "0.1.23" | 1339 | version = "0.1.23" |
1075 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1340 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1166,9 +1431,9 @@ dependencies = [ | |||
1166 | 1431 | ||
1167 | [[package]] | 1432 | [[package]] |
1168 | name = "serde_spanned" | 1433 | name = "serde_spanned" |
1169 | version = "0.6.2" | 1434 | version = "0.6.7" |
1170 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1435 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1171 | checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" | 1436 | checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" |
1172 | dependencies = [ | 1437 | dependencies = [ |
1173 | "serde", | 1438 | "serde", |
1174 | ] | 1439 | ] |
@@ -1186,6 +1451,17 @@ dependencies = [ | |||
1186 | ] | 1451 | ] |
1187 | 1452 | ||
1188 | [[package]] | 1453 | [[package]] |
1454 | name = "sha2" | ||
1455 | version = "0.10.8" | ||
1456 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1457 | checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" | ||
1458 | dependencies = [ | ||
1459 | "cfg-if", | ||
1460 | "cpufeatures", | ||
1461 | "digest", | ||
1462 | ] | ||
1463 | |||
1464 | [[package]] | ||
1189 | name = "signal-hook-registry" | 1465 | name = "signal-hook-registry" |
1190 | version = "1.4.1" | 1466 | version = "1.4.1" |
1191 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1467 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1227,9 +1503,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" | |||
1227 | 1503 | ||
1228 | [[package]] | 1504 | [[package]] |
1229 | name = "syn" | 1505 | name = "syn" |
1230 | version = "2.0.17" | 1506 | version = "2.0.77" |
1231 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1507 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1232 | checksum = "45b6ddbb36c5b969c182aec3c4a0bce7df3fbad4b77114706a49aacc80567388" | 1508 | checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" |
1233 | dependencies = [ | 1509 | dependencies = [ |
1234 | "proc-macro2", | 1510 | "proc-macro2", |
1235 | "quote", | 1511 | "quote", |
@@ -1281,6 +1557,15 @@ dependencies = [ | |||
1281 | ] | 1557 | ] |
1282 | 1558 | ||
1283 | [[package]] | 1559 | [[package]] |
1560 | name = "tiny-keccak" | ||
1561 | version = "2.0.2" | ||
1562 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1563 | checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" | ||
1564 | dependencies = [ | ||
1565 | "crunchy", | ||
1566 | ] | ||
1567 | |||
1568 | [[package]] | ||
1284 | name = "tinyvec" | 1569 | name = "tinyvec" |
1285 | version = "1.6.0" | 1570 | version = "1.6.0" |
1286 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1571 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1358,14 +1643,26 @@ dependencies = [ | |||
1358 | "serde", | 1643 | "serde", |
1359 | "serde_spanned", | 1644 | "serde_spanned", |
1360 | "toml_datetime", | 1645 | "toml_datetime", |
1361 | "toml_edit", | 1646 | "toml_edit 0.19.10", |
1647 | ] | ||
1648 | |||
1649 | [[package]] | ||
1650 | name = "toml" | ||
1651 | version = "0.8.19" | ||
1652 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1653 | checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" | ||
1654 | dependencies = [ | ||
1655 | "serde", | ||
1656 | "serde_spanned", | ||
1657 | "toml_datetime", | ||
1658 | "toml_edit 0.22.20", | ||
1362 | ] | 1659 | ] |
1363 | 1660 | ||
1364 | [[package]] | 1661 | [[package]] |
1365 | name = "toml_datetime" | 1662 | name = "toml_datetime" |
1366 | version = "0.6.2" | 1663 | version = "0.6.8" |
1367 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1664 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1368 | checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" | 1665 | checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" |
1369 | dependencies = [ | 1666 | dependencies = [ |
1370 | "serde", | 1667 | "serde", |
1371 | ] | 1668 | ] |
@@ -1376,11 +1673,24 @@ version = "0.19.10" | |||
1376 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1673 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1377 | checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" | 1674 | checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" |
1378 | dependencies = [ | 1675 | dependencies = [ |
1379 | "indexmap", | 1676 | "indexmap 1.9.3", |
1380 | "serde", | 1677 | "serde", |
1381 | "serde_spanned", | 1678 | "serde_spanned", |
1382 | "toml_datetime", | 1679 | "toml_datetime", |
1383 | "winnow", | 1680 | "winnow 0.4.6", |
1681 | ] | ||
1682 | |||
1683 | [[package]] | ||
1684 | name = "toml_edit" | ||
1685 | version = "0.22.20" | ||
1686 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1687 | checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" | ||
1688 | dependencies = [ | ||
1689 | "indexmap 2.5.0", | ||
1690 | "serde", | ||
1691 | "serde_spanned", | ||
1692 | "toml_datetime", | ||
1693 | "winnow 0.6.18", | ||
1384 | ] | 1694 | ] |
1385 | 1695 | ||
1386 | [[package]] | 1696 | [[package]] |
@@ -1416,6 +1726,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1416 | checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" | 1726 | checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" |
1417 | 1727 | ||
1418 | [[package]] | 1728 | [[package]] |
1729 | name = "typenum" | ||
1730 | version = "1.17.0" | ||
1731 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1732 | checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" | ||
1733 | |||
1734 | [[package]] | ||
1735 | name = "ucd-trie" | ||
1736 | version = "0.1.6" | ||
1737 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1738 | checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" | ||
1739 | |||
1740 | [[package]] | ||
1419 | name = "unicode-bidi" | 1741 | name = "unicode-bidi" |
1420 | version = "0.3.13" | 1742 | version = "0.3.13" |
1421 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1743 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1437,6 +1759,12 @@ dependencies = [ | |||
1437 | ] | 1759 | ] |
1438 | 1760 | ||
1439 | [[package]] | 1761 | [[package]] |
1762 | name = "unicode-segmentation" | ||
1763 | version = "1.11.0" | ||
1764 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1765 | checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" | ||
1766 | |||
1767 | [[package]] | ||
1440 | name = "unicode-width" | 1768 | name = "unicode-width" |
1441 | version = "0.1.10" | 1769 | version = "0.1.10" |
1442 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1770 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1770,6 +2098,15 @@ dependencies = [ | |||
1770 | ] | 2098 | ] |
1771 | 2099 | ||
1772 | [[package]] | 2100 | [[package]] |
2101 | name = "winnow" | ||
2102 | version = "0.6.18" | ||
2103 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
2104 | checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" | ||
2105 | dependencies = [ | ||
2106 | "memchr", | ||
2107 | ] | ||
2108 | |||
2109 | [[package]] | ||
1773 | name = "winreg" | 2110 | name = "winreg" |
1774 | version = "0.10.1" | 2111 | version = "0.10.1" |
1775 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2112 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1777,3 +2114,12 @@ checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" | |||
1777 | dependencies = [ | 2114 | dependencies = [ |
1778 | "winapi", | 2115 | "winapi", |
1779 | ] | 2116 | ] |
2117 | |||
2118 | [[package]] | ||
2119 | name = "yaml-rust" | ||
2120 | version = "0.4.5" | ||
2121 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
2122 | checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" | ||
2123 | dependencies = [ | ||
2124 | "linked-hash-map", | ||
2125 | ] | ||
@@ -19,3 +19,4 @@ dirs = "5.0.0" | |||
19 | clap = { version = "4.2.1", features = ["derive"] } | 19 | clap = { version = "4.2.1", features = ["derive"] } |
20 | clap_complete = "4.2.0" | 20 | clap_complete = "4.2.0" |
21 | indicatif = "0.17.3" | 21 | indicatif = "0.17.3" |
22 | config = "0.14.0" | ||
diff --git a/src/config.rs b/src/config.rs index 6280932..8ecdc69 100644 --- a/src/config.rs +++ b/src/config.rs | |||
@@ -1,14 +1,16 @@ | |||
1 | use std::{ | 1 | use std::{ |
2 | fs::{create_dir_all, File}, | 2 | fs::{create_dir_all, File}, |
3 | io::{Read, Write}, | 3 | io::Write, |
4 | path::Path, | 4 | path::Path, |
5 | }; | 5 | }; |
6 | 6 | ||
7 | use indicatif::{ProgressBar, ProgressStyle}; | ||
8 | use serde::{Deserialize, Serialize}; | 7 | use serde::{Deserialize, Serialize}; |
9 | 8 | ||
10 | use crate::{ | 9 | use crate::{ |
11 | check_game_versions, db::setup, error::{EType, MLErr, MLE}, Modloader, VersionLevel, | 10 | check_game_versions, |
11 | db::setup, | ||
12 | error::{EType, MLErr, MLE}, | ||
13 | Modloader, VersionLevel, | ||
12 | }; | 14 | }; |
13 | 15 | ||
14 | #[derive(Debug, Clone, Serialize, Deserialize)] | 16 | #[derive(Debug, Clone, Serialize, Deserialize)] |
@@ -20,6 +22,28 @@ pub struct Cfg { | |||
20 | pub apis: Apis, | 22 | pub apis: Apis, |
21 | } | 23 | } |
22 | 24 | ||
25 | impl Default for Cfg { | ||
26 | fn default() -> Self { | ||
27 | let cache_dir = dirs::cache_dir() | ||
28 | .unwrap() | ||
29 | .join("modlist") | ||
30 | .to_string_lossy() | ||
31 | .to_string(); | ||
32 | Self { | ||
33 | data: cache_dir.clone(), | ||
34 | cache: format!("{cache_dir}/cache"), | ||
35 | versions: cache_dir, | ||
36 | defaults: Defaults { | ||
37 | modloader: Modloader::Fabric, | ||
38 | version: VersionLevel::Release, | ||
39 | }, | ||
40 | apis: Apis { | ||
41 | modrinth: String::from("https://api.modrinth.com/v2/"), | ||
42 | }, | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | |||
23 | #[derive(Debug, Clone, Serialize, Deserialize)] | 47 | #[derive(Debug, Clone, Serialize, Deserialize)] |
24 | pub struct Apis { | 48 | pub struct Apis { |
25 | pub modrinth: String, | 49 | pub modrinth: String, |
@@ -44,21 +68,24 @@ impl Cfg { | |||
44 | .to_string(), | 68 | .to_string(), |
45 | }; | 69 | }; |
46 | 70 | ||
47 | let mut file = match File::open(&configfile) { | 71 | if let Some(err) = File::open(&configfile).err() { |
48 | Ok(file) => file, | 72 | if err.kind() == std::io::ErrorKind::NotFound && path.is_none() { |
49 | Err(err) => { | 73 | create_config(&configfile)?; |
50 | if err.kind() == std::io::ErrorKind::NotFound && path.is_none() | 74 | } else { |
51 | { | 75 | return Err(err.into()); |
52 | create_config(&configfile)?; | 76 | }; |
53 | File::open(&configfile)? | ||
54 | } else { | ||
55 | return Err(err.into()); | ||
56 | } | ||
57 | } | ||
58 | }; | 77 | }; |
59 | let mut content = String::new(); | 78 | |
60 | file.read_to_string(&mut content)?; | 79 | let config: Cfg = config::Config::builder() |
61 | let config = toml::from_str::<Cfg>(&content)?; | 80 | .add_source(config::File::with_name(&configfile).required(false)) |
81 | .add_source( | ||
82 | config::Environment::with_prefix("MODLIST").separator("_"), | ||
83 | ) | ||
84 | .build() | ||
85 | .unwrap() | ||
86 | .try_deserialize() | ||
87 | .unwrap(); | ||
88 | |||
62 | //Check cache | 89 | //Check cache |
63 | if !Path::new(&config.cache).exists() { | 90 | if !Path::new(&config.cache).exists() { |
64 | create_cache(&config.cache)?; | 91 | create_cache(&config.cache)?; |
@@ -81,60 +108,28 @@ impl Cfg { | |||
81 | } | 108 | } |
82 | 109 | ||
83 | fn create_config(path: &str) -> MLE<()> { | 110 | fn create_config(path: &str) -> MLE<()> { |
84 | let p = ProgressBar::new(1); | ||
85 | p.set_style(ProgressStyle::with_template("{wide_msg}").unwrap()); | ||
86 | p.set_message("Create default config"); | ||
87 | |||
88 | let cache_dir = dirs::cache_dir() | ||
89 | .unwrap() | ||
90 | .join("modlist") | ||
91 | .to_string_lossy() | ||
92 | .to_string(); | ||
93 | let default_cfg = Cfg { | ||
94 | data: cache_dir.clone(), | ||
95 | cache: format!("{cache_dir}/cache"), | ||
96 | versions: cache_dir, | ||
97 | defaults: Defaults { | ||
98 | modloader: Modloader::Fabric, | ||
99 | version: VersionLevel::Release, | ||
100 | }, | ||
101 | apis: Apis { | ||
102 | modrinth: String::from("https://api.modrinth.com/v2/"), | ||
103 | }, | ||
104 | }; | ||
105 | create_dir_all(path.split("config.toml").collect::<Vec<&str>>()[0])?; | 111 | create_dir_all(path.split("config.toml").collect::<Vec<&str>>()[0])?; |
106 | let mut file = File::create(path)?; | 112 | let mut file = File::create(path)?; |
107 | file.write_all(toml::to_string(&default_cfg)?.as_bytes())?; | 113 | file.write_all(toml::to_string(&Cfg::default())?.as_bytes())?; |
108 | p.finish_with_message(format!("Created default config ({path})")); | 114 | println!("Created default config ({path})"); |
109 | Ok(()) | 115 | Ok(()) |
110 | } | 116 | } |
111 | 117 | ||
112 | fn create_database(path: &str) -> MLE<()> { | 118 | fn create_database(path: &str) -> MLE<()> { |
113 | let p = ProgressBar::new(1); | ||
114 | p.set_style(ProgressStyle::with_template("{wide_msg}").unwrap()); | ||
115 | p.set_message("Create database"); | ||
116 | |||
117 | File::create(path)?; | 119 | File::create(path)?; |
118 | setup(path)?; | 120 | setup(path)?; |
119 | p.finish_with_message(format!("Created database ({path})")); | 121 | println!("Created database ({path})"); |
120 | Ok(()) | 122 | Ok(()) |
121 | } | 123 | } |
122 | 124 | ||
123 | fn create_cache(path: &str) -> MLE<()> { | 125 | fn create_cache(path: &str) -> MLE<()> { |
124 | let p = ProgressBar::new(1); | ||
125 | p.set_style(ProgressStyle::with_template("{wide_msg}").unwrap()); | ||
126 | p.set_message("Create cache"); | ||
127 | |||
128 | create_dir_all(path)?; | 126 | create_dir_all(path)?; |
129 | p.finish_with_message(format!("Created cache ({path})")); | 127 | println!("Created cache ({path})"); |
130 | Ok(()) | 128 | Ok(()) |
131 | } | 129 | } |
132 | 130 | ||
133 | fn create_versions_dummy(path: &str) -> MLE<()> { | 131 | fn create_versions_dummy(path: &str) -> MLE<()> { |
134 | let p = ProgressBar::new(1); | ||
135 | p.set_style(ProgressStyle::with_template("{wide_msg}").unwrap()); | ||
136 | p.set_message("Create version file"); | ||
137 | File::create(path)?; | 132 | File::create(path)?; |
138 | p.finish_with_message(format!("Created version file ({path})")); | 133 | println!("Created version file ({path})"); |
139 | Ok(()) | 134 | Ok(()) |
140 | } | 135 | } |