diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Cargo.lock | 310 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | config.ini | 7 | ||||
-rw-r--r-- | src/config.rs | 40 | ||||
-rw-r--r-- | src/error.rs | 33 | ||||
-rw-r--r-- | src/main.rs | 2 |
7 files changed, 124 insertions, 273 deletions
@@ -6,3 +6,4 @@ | |||
6 | .planmodlist.autosave.xopp | 6 | .planmodlist.autosave.xopp |
7 | data.db.cp | 7 | data.db.cp |
8 | export.toml | 8 | export.toml |
9 | config.toml | ||
@@ -3,6 +3,21 @@ | |||
3 | version = 3 | 3 | version = 3 |
4 | 4 | ||
5 | [[package]] | 5 | [[package]] |
6 | name = "addr2line" | ||
7 | version = "0.19.0" | ||
8 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
9 | checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" | ||
10 | dependencies = [ | ||
11 | "gimli", | ||
12 | ] | ||
13 | |||
14 | [[package]] | ||
15 | name = "adler" | ||
16 | version = "1.0.2" | ||
17 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" | ||
19 | |||
20 | [[package]] | ||
6 | name = "ahash" | 21 | name = "ahash" |
7 | version = "0.7.6" | 22 | version = "0.7.6" |
8 | source = "registry+https://github.com/rust-lang/crates.io-index" | 23 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -23,23 +38,27 @@ dependencies = [ | |||
23 | ] | 38 | ] |
24 | 39 | ||
25 | [[package]] | 40 | [[package]] |
26 | name = "async-trait" | ||
27 | version = "0.1.59" | ||
28 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
29 | checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" | ||
30 | dependencies = [ | ||
31 | "proc-macro2", | ||
32 | "quote", | ||
33 | "syn", | ||
34 | ] | ||
35 | |||
36 | [[package]] | ||
37 | name = "autocfg" | 41 | name = "autocfg" |
38 | version = "1.1.0" | 42 | version = "1.1.0" |
39 | source = "registry+https://github.com/rust-lang/crates.io-index" | 43 | source = "registry+https://github.com/rust-lang/crates.io-index" |
40 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" | 44 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" |
41 | 45 | ||
42 | [[package]] | 46 | [[package]] |
47 | name = "backtrace" | ||
48 | version = "0.3.67" | ||
49 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
50 | checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" | ||
51 | dependencies = [ | ||
52 | "addr2line", | ||
53 | "cc", | ||
54 | "cfg-if", | ||
55 | "libc", | ||
56 | "miniz_oxide", | ||
57 | "object", | ||
58 | "rustc-demangle", | ||
59 | ] | ||
60 | |||
61 | [[package]] | ||
43 | name = "base64" | 62 | name = "base64" |
44 | version = "0.13.1" | 63 | version = "0.13.1" |
45 | source = "registry+https://github.com/rust-lang/crates.io-index" | 64 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -52,15 +71,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
52 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" | 71 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" |
53 | 72 | ||
54 | [[package]] | 73 | [[package]] |
55 | name = "block-buffer" | ||
56 | version = "0.10.3" | ||
57 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
58 | checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" | ||
59 | dependencies = [ | ||
60 | "generic-array", | ||
61 | ] | ||
62 | |||
63 | [[package]] | ||
64 | name = "bumpalo" | 74 | name = "bumpalo" |
65 | version = "3.11.1" | 75 | version = "3.11.1" |
66 | source = "registry+https://github.com/rust-lang/crates.io-index" | 76 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -110,25 +120,6 @@ dependencies = [ | |||
110 | ] | 120 | ] |
111 | 121 | ||
112 | [[package]] | 122 | [[package]] |
113 | name = "config" | ||
114 | version = "0.13.3" | ||
115 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
116 | checksum = "d379af7f68bfc21714c6c7dea883544201741d2ce8274bb12fa54f89507f52a7" | ||
117 | dependencies = [ | ||
118 | "async-trait", | ||
119 | "json5", | ||
120 | "lazy_static", | ||
121 | "nom", | ||
122 | "pathdiff", | ||
123 | "ron", | ||
124 | "rust-ini", | ||
125 | "serde", | ||
126 | "serde_json", | ||
127 | "toml", | ||
128 | "yaml-rust", | ||
129 | ] | ||
130 | |||
131 | [[package]] | ||
132 | name = "core-foundation" | 123 | name = "core-foundation" |
133 | version = "0.9.3" | 124 | version = "0.9.3" |
134 | source = "registry+https://github.com/rust-lang/crates.io-index" | 125 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -145,25 +136,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
145 | checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" | 136 | checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" |
146 | 137 | ||
147 | [[package]] | 138 | [[package]] |
148 | name = "cpufeatures" | ||
149 | version = "0.2.5" | ||
150 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
151 | checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" | ||
152 | dependencies = [ | ||
153 | "libc", | ||
154 | ] | ||
155 | |||
156 | [[package]] | ||
157 | name = "crypto-common" | ||
158 | version = "0.1.6" | ||
159 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
160 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" | ||
161 | dependencies = [ | ||
162 | "generic-array", | ||
163 | "typenum", | ||
164 | ] | ||
165 | |||
166 | [[package]] | ||
167 | name = "cxx" | 139 | name = "cxx" |
168 | version = "1.0.83" | 140 | version = "1.0.83" |
169 | source = "registry+https://github.com/rust-lang/crates.io-index" | 141 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -208,28 +180,22 @@ dependencies = [ | |||
208 | ] | 180 | ] |
209 | 181 | ||
210 | [[package]] | 182 | [[package]] |
211 | name = "digest" | 183 | name = "encoding_rs" |
212 | version = "0.10.6" | 184 | version = "0.8.31" |
213 | source = "registry+https://github.com/rust-lang/crates.io-index" | 185 | source = "registry+https://github.com/rust-lang/crates.io-index" |
214 | checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" | 186 | checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" |
215 | dependencies = [ | 187 | dependencies = [ |
216 | "block-buffer", | 188 | "cfg-if", |
217 | "crypto-common", | ||
218 | ] | 189 | ] |
219 | 190 | ||
220 | [[package]] | 191 | [[package]] |
221 | name = "dlv-list" | 192 | name = "error-chain" |
222 | version = "0.3.0" | 193 | version = "0.12.4" |
223 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
224 | checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" | ||
225 | |||
226 | [[package]] | ||
227 | name = "encoding_rs" | ||
228 | version = "0.8.31" | ||
229 | source = "registry+https://github.com/rust-lang/crates.io-index" | 194 | source = "registry+https://github.com/rust-lang/crates.io-index" |
230 | checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" | 195 | checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" |
231 | dependencies = [ | 196 | dependencies = [ |
232 | "cfg-if", | 197 | "backtrace", |
198 | "version_check", | ||
233 | ] | 199 | ] |
234 | 200 | ||
235 | [[package]] | 201 | [[package]] |
@@ -336,16 +302,6 @@ dependencies = [ | |||
336 | ] | 302 | ] |
337 | 303 | ||
338 | [[package]] | 304 | [[package]] |
339 | name = "generic-array" | ||
340 | version = "0.14.6" | ||
341 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
342 | checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" | ||
343 | dependencies = [ | ||
344 | "typenum", | ||
345 | "version_check", | ||
346 | ] | ||
347 | |||
348 | [[package]] | ||
349 | name = "getrandom" | 305 | name = "getrandom" |
350 | version = "0.2.8" | 306 | version = "0.2.8" |
351 | source = "registry+https://github.com/rust-lang/crates.io-index" | 307 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -357,6 +313,12 @@ dependencies = [ | |||
357 | ] | 313 | ] |
358 | 314 | ||
359 | [[package]] | 315 | [[package]] |
316 | name = "gimli" | ||
317 | version = "0.27.0" | ||
318 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
319 | checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793" | ||
320 | |||
321 | [[package]] | ||
360 | name = "h2" | 322 | name = "h2" |
361 | version = "0.3.15" | 323 | version = "0.3.15" |
362 | source = "registry+https://github.com/rust-lang/crates.io-index" | 324 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -548,17 +510,6 @@ dependencies = [ | |||
548 | ] | 510 | ] |
549 | 511 | ||
550 | [[package]] | 512 | [[package]] |
551 | name = "json5" | ||
552 | version = "0.4.1" | ||
553 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
554 | checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" | ||
555 | dependencies = [ | ||
556 | "pest", | ||
557 | "pest_derive", | ||
558 | "serde", | ||
559 | ] | ||
560 | |||
561 | [[package]] | ||
562 | name = "lazy_static" | 513 | name = "lazy_static" |
563 | version = "1.4.0" | 514 | version = "1.4.0" |
564 | source = "registry+https://github.com/rust-lang/crates.io-index" | 515 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -591,12 +542,6 @@ dependencies = [ | |||
591 | ] | 542 | ] |
592 | 543 | ||
593 | [[package]] | 544 | [[package]] |
594 | name = "linked-hash-map" | ||
595 | version = "0.5.6" | ||
596 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
597 | checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" | ||
598 | |||
599 | [[package]] | ||
600 | name = "lock_api" | 545 | name = "lock_api" |
601 | version = "0.4.9" | 546 | version = "0.4.9" |
602 | source = "registry+https://github.com/rust-lang/crates.io-index" | 547 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -628,10 +573,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
628 | checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" | 573 | checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" |
629 | 574 | ||
630 | [[package]] | 575 | [[package]] |
631 | name = "minimal-lexical" | 576 | name = "miniz_oxide" |
632 | version = "0.2.1" | 577 | version = "0.6.2" |
633 | source = "registry+https://github.com/rust-lang/crates.io-index" | 578 | source = "registry+https://github.com/rust-lang/crates.io-index" |
634 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" | 579 | checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" |
580 | dependencies = [ | ||
581 | "adler", | ||
582 | ] | ||
635 | 583 | ||
636 | [[package]] | 584 | [[package]] |
637 | name = "mio" | 585 | name = "mio" |
@@ -647,10 +595,10 @@ dependencies = [ | |||
647 | 595 | ||
648 | [[package]] | 596 | [[package]] |
649 | name = "modlist" | 597 | name = "modlist" |
650 | version = "0.6.0" | 598 | version = "0.6.2" |
651 | dependencies = [ | 599 | dependencies = [ |
652 | "chrono", | 600 | "chrono", |
653 | "config", | 601 | "error-chain", |
654 | "futures-util", | 602 | "futures-util", |
655 | "reqwest", | 603 | "reqwest", |
656 | "rusqlite", | 604 | "rusqlite", |
@@ -679,16 +627,6 @@ dependencies = [ | |||
679 | ] | 627 | ] |
680 | 628 | ||
681 | [[package]] | 629 | [[package]] |
682 | name = "nom" | ||
683 | version = "7.1.1" | ||
684 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
685 | checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" | ||
686 | dependencies = [ | ||
687 | "memchr", | ||
688 | "minimal-lexical", | ||
689 | ] | ||
690 | |||
691 | [[package]] | ||
692 | name = "num-integer" | 630 | name = "num-integer" |
693 | version = "0.1.45" | 631 | version = "0.1.45" |
694 | source = "registry+https://github.com/rust-lang/crates.io-index" | 632 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -718,6 +656,15 @@ dependencies = [ | |||
718 | ] | 656 | ] |
719 | 657 | ||
720 | [[package]] | 658 | [[package]] |
659 | name = "object" | ||
660 | version = "0.30.0" | ||
661 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
662 | checksum = "239da7f290cfa979f43f85a8efeee9a8a76d0827c356d37f9d3d7254d6b537fb" | ||
663 | dependencies = [ | ||
664 | "memchr", | ||
665 | ] | ||
666 | |||
667 | [[package]] | ||
721 | name = "once_cell" | 668 | name = "once_cell" |
722 | version = "1.16.0" | 669 | version = "1.16.0" |
723 | source = "registry+https://github.com/rust-lang/crates.io-index" | 670 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -769,16 +716,6 @@ dependencies = [ | |||
769 | ] | 716 | ] |
770 | 717 | ||
771 | [[package]] | 718 | [[package]] |
772 | name = "ordered-multimap" | ||
773 | version = "0.4.3" | ||
774 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
775 | checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" | ||
776 | dependencies = [ | ||
777 | "dlv-list", | ||
778 | "hashbrown", | ||
779 | ] | ||
780 | |||
781 | [[package]] | ||
782 | name = "parking_lot" | 719 | name = "parking_lot" |
783 | version = "0.12.1" | 720 | version = "0.12.1" |
784 | source = "registry+https://github.com/rust-lang/crates.io-index" | 721 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -802,62 +739,12 @@ dependencies = [ | |||
802 | ] | 739 | ] |
803 | 740 | ||
804 | [[package]] | 741 | [[package]] |
805 | name = "pathdiff" | ||
806 | version = "0.2.1" | ||
807 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
808 | checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" | ||
809 | |||
810 | [[package]] | ||
811 | name = "percent-encoding" | 742 | name = "percent-encoding" |
812 | version = "2.2.0" | 743 | version = "2.2.0" |
813 | source = "registry+https://github.com/rust-lang/crates.io-index" | 744 | source = "registry+https://github.com/rust-lang/crates.io-index" |
814 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" | 745 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" |
815 | 746 | ||
816 | [[package]] | 747 | [[package]] |
817 | name = "pest" | ||
818 | version = "2.5.1" | ||
819 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
820 | checksum = "cc8bed3549e0f9b0a2a78bf7c0018237a2cdf085eecbbc048e52612438e4e9d0" | ||
821 | dependencies = [ | ||
822 | "thiserror", | ||
823 | "ucd-trie", | ||
824 | ] | ||
825 | |||
826 | [[package]] | ||
827 | name = "pest_derive" | ||
828 | version = "2.5.1" | ||
829 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
830 | checksum = "cdc078600d06ff90d4ed238f0119d84ab5d43dbaad278b0e33a8820293b32344" | ||
831 | dependencies = [ | ||
832 | "pest", | ||
833 | "pest_generator", | ||
834 | ] | ||
835 | |||
836 | [[package]] | ||
837 | name = "pest_generator" | ||
838 | version = "2.5.1" | ||
839 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
840 | checksum = "28a1af60b1c4148bb269006a750cff8e2ea36aff34d2d96cf7be0b14d1bed23c" | ||
841 | dependencies = [ | ||
842 | "pest", | ||
843 | "pest_meta", | ||
844 | "proc-macro2", | ||
845 | "quote", | ||
846 | "syn", | ||
847 | ] | ||
848 | |||
849 | [[package]] | ||
850 | name = "pest_meta" | ||
851 | version = "2.5.1" | ||
852 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
853 | checksum = "fec8605d59fc2ae0c6c1aefc0c7c7a9769732017c0ce07f7a9cfffa7b4404f20" | ||
854 | dependencies = [ | ||
855 | "once_cell", | ||
856 | "pest", | ||
857 | "sha1", | ||
858 | ] | ||
859 | |||
860 | [[package]] | ||
861 | name = "pin-project-lite" | 748 | name = "pin-project-lite" |
862 | version = "0.2.9" | 749 | version = "0.2.9" |
863 | source = "registry+https://github.com/rust-lang/crates.io-index" | 750 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -950,17 +837,6 @@ dependencies = [ | |||
950 | ] | 837 | ] |
951 | 838 | ||
952 | [[package]] | 839 | [[package]] |
953 | name = "ron" | ||
954 | version = "0.7.1" | ||
955 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
956 | checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" | ||
957 | dependencies = [ | ||
958 | "base64", | ||
959 | "bitflags", | ||
960 | "serde", | ||
961 | ] | ||
962 | |||
963 | [[package]] | ||
964 | name = "rusqlite" | 840 | name = "rusqlite" |
965 | version = "0.28.0" | 841 | version = "0.28.0" |
966 | source = "registry+https://github.com/rust-lang/crates.io-index" | 842 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -975,14 +851,10 @@ dependencies = [ | |||
975 | ] | 851 | ] |
976 | 852 | ||
977 | [[package]] | 853 | [[package]] |
978 | name = "rust-ini" | 854 | name = "rustc-demangle" |
979 | version = "0.18.0" | 855 | version = "0.1.21" |
980 | source = "registry+https://github.com/rust-lang/crates.io-index" | 856 | source = "registry+https://github.com/rust-lang/crates.io-index" |
981 | checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" | 857 | checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" |
982 | dependencies = [ | ||
983 | "cfg-if", | ||
984 | "ordered-multimap", | ||
985 | ] | ||
986 | 858 | ||
987 | [[package]] | 859 | [[package]] |
988 | name = "ryu" | 860 | name = "ryu" |
@@ -1079,17 +951,6 @@ dependencies = [ | |||
1079 | ] | 951 | ] |
1080 | 952 | ||
1081 | [[package]] | 953 | [[package]] |
1082 | name = "sha1" | ||
1083 | version = "0.10.5" | ||
1084 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1085 | checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" | ||
1086 | dependencies = [ | ||
1087 | "cfg-if", | ||
1088 | "cpufeatures", | ||
1089 | "digest", | ||
1090 | ] | ||
1091 | |||
1092 | [[package]] | ||
1093 | name = "signal-hook-registry" | 954 | name = "signal-hook-registry" |
1094 | version = "1.4.0" | 955 | version = "1.4.0" |
1095 | source = "registry+https://github.com/rust-lang/crates.io-index" | 956 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1158,26 +1019,6 @@ dependencies = [ | |||
1158 | ] | 1019 | ] |
1159 | 1020 | ||
1160 | [[package]] | 1021 | [[package]] |
1161 | name = "thiserror" | ||
1162 | version = "1.0.37" | ||
1163 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1164 | checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" | ||
1165 | dependencies = [ | ||
1166 | "thiserror-impl", | ||
1167 | ] | ||
1168 | |||
1169 | [[package]] | ||
1170 | name = "thiserror-impl" | ||
1171 | version = "1.0.37" | ||
1172 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1173 | checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" | ||
1174 | dependencies = [ | ||
1175 | "proc-macro2", | ||
1176 | "quote", | ||
1177 | "syn", | ||
1178 | ] | ||
1179 | |||
1180 | [[package]] | ||
1181 | name = "time" | 1022 | name = "time" |
1182 | version = "0.1.45" | 1023 | version = "0.1.45" |
1183 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1024 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1300,18 +1141,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1300 | checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" | 1141 | checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" |
1301 | 1142 | ||
1302 | [[package]] | 1143 | [[package]] |
1303 | name = "typenum" | ||
1304 | version = "1.16.0" | ||
1305 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1306 | checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" | ||
1307 | |||
1308 | [[package]] | ||
1309 | name = "ucd-trie" | ||
1310 | version = "0.1.5" | ||
1311 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1312 | checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" | ||
1313 | |||
1314 | [[package]] | ||
1315 | name = "unicode-bidi" | 1144 | name = "unicode-bidi" |
1316 | version = "0.3.8" | 1145 | version = "0.3.8" |
1317 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1146 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1598,12 +1427,3 @@ checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" | |||
1598 | dependencies = [ | 1427 | dependencies = [ |
1599 | "winapi", | 1428 | "winapi", |
1600 | ] | 1429 | ] |
1601 | |||
1602 | [[package]] | ||
1603 | name = "yaml-rust" | ||
1604 | version = "0.4.5" | ||
1605 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1606 | checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" | ||
1607 | dependencies = [ | ||
1608 | "linked-hash-map", | ||
1609 | ] | ||
@@ -1,6 +1,6 @@ | |||
1 | [package] | 1 | [package] |
2 | name = "modlist" | 2 | name = "modlist" |
3 | version = "0.6.1" | 3 | version = "0.6.2" |
4 | edition = "2021" | 4 | edition = "2021" |
5 | 5 | ||
6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
@@ -10,8 +10,8 @@ reqwest = { version = "0.11", features = ["json", "stream"] } | |||
10 | tokio = { version = "1", features = ["full"] } | 10 | tokio = { version = "1", features = ["full"] } |
11 | serde = { version = "1.0", features = ["derive"] } | 11 | serde = { version = "1.0", features = ["derive"] } |
12 | serde_json = "1.0.87" | 12 | serde_json = "1.0.87" |
13 | config = "0.13.2" | ||
14 | rusqlite = { version = "0.28.0", features = ["bundled"] } | 13 | rusqlite = { version = "0.28.0", features = ["bundled"] } |
15 | futures-util = "0.3.14" | 14 | futures-util = "0.3.14" |
16 | chrono = "0.4.22" | 15 | chrono = "0.4.22" |
17 | toml = "0.5.10" | 16 | toml = "0.5.10" |
17 | error-chain = "0.12.4" | ||
diff --git a/config.ini b/config.ini deleted file mode 100644 index 345a13a..0000000 --- a/config.ini +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | data = "./" | ||
2 | clean_remove = false | ||
3 | downloads = "./dl" | ||
4 | |||
5 | [apis] | ||
6 | modrinth = "http://localhost:8080/" | ||
7 | ;modrinth = "https://api.modrinth.com/v2/" | ||
diff --git a/src/config.rs b/src/config.rs index ad59963..99d2ec2 100644 --- a/src/config.rs +++ b/src/config.rs | |||
@@ -1,27 +1,39 @@ | |||
1 | use config::{Config, File, FileFormat}; | 1 | use std::{fs::File, io::{Read, Write}}; |
2 | use serde::Deserialize; | ||
3 | 2 | ||
4 | #[derive(Debug, Clone, Deserialize)] | 3 | use serde::{Serialize, Deserialize}; |
4 | |||
5 | use crate::error::MLE; | ||
6 | |||
7 | #[derive(Debug, Clone, Serialize, Deserialize)] | ||
5 | pub struct Cfg { | 8 | pub struct Cfg { |
6 | pub data: String, | 9 | pub data: String, |
7 | pub downloads: String, | ||
8 | pub clean_remove: bool, | ||
9 | pub apis: Apis, | 10 | pub apis: Apis, |
10 | } | 11 | } |
11 | 12 | ||
12 | #[derive(Debug, Clone, Deserialize)] | 13 | #[derive(Debug, Clone, Serialize, Deserialize)] |
13 | pub struct Apis { | 14 | pub struct Apis { |
14 | pub modrinth: String, | 15 | pub modrinth: String, |
15 | } | 16 | } |
16 | 17 | ||
17 | impl Cfg { | 18 | impl Cfg { |
18 | pub fn init(path: &str) -> Self { | 19 | pub fn init(path: &str) -> MLE<Self> { |
19 | //TODO Error Handling | 20 | let mut file = match File::open(path) { |
20 | Config::builder() | 21 | Ok(file) => file, |
21 | .add_source(File::new(path, FileFormat::Ini)) | 22 | Err(err) => { |
22 | .build() | 23 | if err.kind() == std::io::ErrorKind::NotFound { |
23 | .unwrap() | 24 | println!("No config file found, creating one"); |
24 | .try_deserialize() | 25 | let default_cfg = Cfg { data: String::from("./"), apis: Apis { modrinth: String::from("https://api.modrinth.com/v2/") } }; |
25 | .unwrap() | 26 | let mut file = File::create(path)?; |
27 | file.write_all(&toml::to_string(&default_cfg)?.as_bytes())?; | ||
28 | File::open(path)? | ||
29 | } else { | ||
30 | return Err(err.into()); | ||
31 | } | ||
32 | } | ||
33 | }; | ||
34 | let mut content = String::new(); | ||
35 | file.read_to_string(&mut content)?; | ||
36 | let config = toml::from_str::<Cfg>(&content)?; | ||
37 | Ok(config) | ||
26 | } | 38 | } |
27 | } | 39 | } |
diff --git a/src/error.rs b/src/error.rs index c82688c..1ac2a48 100644 --- a/src/error.rs +++ b/src/error.rs | |||
@@ -1,16 +1,20 @@ | |||
1 | use core::fmt; | 1 | use core::fmt; |
2 | use serde::Deserialize; | ||
2 | 3 | ||
3 | pub type MLE<T> = Result<T, MLError>; | 4 | pub type MLE<T> = Result<T, MLError>; |
4 | 5 | ||
5 | #[derive(Debug)] | 6 | #[derive(Debug, Deserialize)] |
6 | pub struct MLError { | 7 | pub struct MLError { |
7 | etype: ErrorType, | 8 | etype: ErrorType, |
8 | message: String, | 9 | message: String, |
9 | } | 10 | } |
10 | 11 | ||
11 | #[derive(Debug)] | 12 | #[derive(Debug, Deserialize)] |
12 | pub enum ErrorType { | 13 | pub enum ErrorType { |
13 | ArgumentError | 14 | ArgumentError, |
15 | ConfigError, | ||
16 | LibToml, | ||
17 | IoError, | ||
14 | } | 18 | } |
15 | 19 | ||
16 | impl std::error::Error for MLError { | 20 | impl std::error::Error for MLError { |
@@ -22,11 +26,32 @@ impl std::error::Error for MLError { | |||
22 | impl fmt::Display for MLError { | 26 | impl fmt::Display for MLError { |
23 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | 27 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
24 | match self.etype { | 28 | match self.etype { |
25 | ErrorType::ArgumentError => write!(f, "ARGS") | 29 | ErrorType::ArgumentError => write!(f, "ARGS"), |
30 | ErrorType::ConfigError => write!(f, "CONFIG"), | ||
31 | ErrorType::LibToml => write!(f, "TOML"), | ||
32 | ErrorType::IoError => write!(f, "IO") | ||
26 | } | 33 | } |
27 | } | 34 | } |
28 | } | 35 | } |
29 | 36 | ||
37 | impl From<toml::de::Error> for MLError { | ||
38 | fn from(error: toml::de::Error) -> Self { | ||
39 | Self { etype: ErrorType::LibToml, message: error.to_string() } | ||
40 | } | ||
41 | } | ||
42 | |||
43 | impl From<toml::ser::Error> for MLError { | ||
44 | fn from(error: toml::ser::Error) -> Self { | ||
45 | Self { etype: ErrorType::LibToml, message: error.to_string() } | ||
46 | } | ||
47 | } | ||
48 | |||
49 | impl From<std::io::Error> for MLError { | ||
50 | fn from(error: std::io::Error) -> Self { | ||
51 | Self { etype: ErrorType::IoError, message: error.to_string() } | ||
52 | } | ||
53 | } | ||
54 | |||
30 | impl MLError { | 55 | impl MLError { |
31 | pub fn new(etype: ErrorType, message: &str) -> Self { | 56 | pub fn new(etype: ErrorType, message: &str) -> Self { |
32 | Self { etype, message: String::from(message) } | 57 | Self { etype, message: String::from(message) } |
diff --git a/src/main.rs b/src/main.rs index 957e5aa..a093bb7 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -2,7 +2,7 @@ use modlist::{config::Cfg, input::get_input}; | |||
2 | 2 | ||
3 | #[tokio::main] | 3 | #[tokio::main] |
4 | async fn main() { | 4 | async fn main() { |
5 | let config = Cfg::init("config.ini"); | 5 | let config = Cfg::init("config.toml").unwrap(); |
6 | //TODO Error Handling | 6 | //TODO Error Handling |
7 | get_input(config).await.unwrap(); | 7 | get_input(config).await.unwrap(); |
8 | } | 8 | } |