summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2019-11-15 18:14:07 +0100
committerMinijackson <minijackson@riseup.net>2019-11-15 18:14:07 +0100
commit304d9f220cc208dd78fce11b703354ecd8d2168c (patch)
tree22c0bc3b13a21c8696d0e20be217c71d8555eabd
parent3301430c676e4af6b95d96b6408a66f9d2768653 (diff)
downloadposeidoc-304d9f220cc208dd78fce11b703354ecd8d2168c.tar.gz
poseidoc-304d9f220cc208dd78fce11b703354ecd8d2168c.zip
add basic config file, use codemap_diagnostic for main errors
-rw-r--r--Cargo.lock158
-rw-r--r--Cargo.toml3
-rw-r--r--res/sample-markdown-project-1/poseidoc.toml1
-rw-r--r--src/cli.rs20
-rw-r--r--src/config.rs107
-rw-r--r--src/main.rs72
6 files changed, 285 insertions, 76 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ad20d8e..f8735bd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -18,7 +18,7 @@ dependencies = [
18 18
19[[package]] 19[[package]]
20name = "anyhow" 20name = "anyhow"
21version = "1.0.12" 21version = "1.0.19"
22source = "registry+https://github.com/rust-lang/crates.io-index" 22source = "registry+https://github.com/rust-lang/crates.io-index"
23 23
24[[package]] 24[[package]]
@@ -26,23 +26,23 @@ name = "atty"
26version = "0.2.13" 26version = "0.2.13"
27source = "registry+https://github.com/rust-lang/crates.io-index" 27source = "registry+https://github.com/rust-lang/crates.io-index"
28dependencies = [ 28dependencies = [
29 "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", 29 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
30 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 30 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
31] 31]
32 32
33[[package]] 33[[package]]
34name = "autocfg" 34name = "autocfg"
35version = "0.1.6" 35version = "0.1.7"
36source = "registry+https://github.com/rust-lang/crates.io-index" 36source = "registry+https://github.com/rust-lang/crates.io-index"
37 37
38[[package]] 38[[package]]
39name = "bitflags" 39name = "bitflags"
40version = "1.2.0" 40version = "1.2.1"
41source = "registry+https://github.com/rust-lang/crates.io-index" 41source = "registry+https://github.com/rust-lang/crates.io-index"
42 42
43[[package]] 43[[package]]
44name = "cfg-if" 44name = "cfg-if"
45version = "0.1.9" 45version = "0.1.10"
46source = "registry+https://github.com/rust-lang/crates.io-index" 46source = "registry+https://github.com/rust-lang/crates.io-index"
47 47
48[[package]] 48[[package]]
@@ -50,9 +50,9 @@ name = "chrono"
50version = "0.4.9" 50version = "0.4.9"
51source = "registry+https://github.com/rust-lang/crates.io-index" 51source = "registry+https://github.com/rust-lang/crates.io-index"
52dependencies = [ 52dependencies = [
53 "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", 53 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
54 "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", 54 "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
55 "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 55 "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
56 "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", 56 "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
57] 57]
58 58
@@ -62,7 +62,7 @@ version = "0.23.0"
62source = "registry+https://github.com/rust-lang/crates.io-index" 62source = "registry+https://github.com/rust-lang/crates.io-index"
63dependencies = [ 63dependencies = [
64 "clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)", 64 "clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)",
65 "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", 65 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
66] 66]
67 67
68[[package]] 68[[package]]
@@ -71,7 +71,7 @@ version = "0.28.1"
71source = "registry+https://github.com/rust-lang/crates.io-index" 71source = "registry+https://github.com/rust-lang/crates.io-index"
72dependencies = [ 72dependencies = [
73 "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 73 "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
74 "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", 74 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
75] 75]
76 76
77[[package]] 77[[package]]
@@ -81,7 +81,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
81dependencies = [ 81dependencies = [
82 "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 82 "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
83 "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", 83 "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
84 "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 84 "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
85 "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 85 "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
86 "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 86 "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
87 "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 87 "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -125,7 +125,7 @@ name = "heck"
125version = "0.3.1" 125version = "0.3.1"
126source = "registry+https://github.com/rust-lang/crates.io-index" 126source = "registry+https://github.com/rust-lang/crates.io-index"
127dependencies = [ 127dependencies = [
128 "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 128 "unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
129] 129]
130 130
131[[package]] 131[[package]]
@@ -133,7 +133,7 @@ name = "hermit-abi"
133version = "0.1.3" 133version = "0.1.3"
134source = "registry+https://github.com/rust-lang/crates.io-index" 134source = "registry+https://github.com/rust-lang/crates.io-index"
135dependencies = [ 135dependencies = [
136 "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", 136 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
137] 137]
138 138
139[[package]] 139[[package]]
@@ -156,7 +156,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
156 156
157[[package]] 157[[package]]
158name = "libc" 158name = "libc"
159version = "0.2.62" 159version = "0.2.65"
160source = "registry+https://github.com/rust-lang/crates.io-index" 160source = "registry+https://github.com/rust-lang/crates.io-index"
161 161
162[[package]] 162[[package]]
@@ -164,7 +164,7 @@ name = "log"
164version = "0.4.8" 164version = "0.4.8"
165source = "registry+https://github.com/rust-lang/crates.io-index" 165source = "registry+https://github.com/rust-lang/crates.io-index"
166dependencies = [ 166dependencies = [
167 "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", 167 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
168] 168]
169 169
170[[package]] 170[[package]]
@@ -177,25 +177,25 @@ name = "num-integer"
177version = "0.1.41" 177version = "0.1.41"
178source = "registry+https://github.com/rust-lang/crates.io-index" 178source = "registry+https://github.com/rust-lang/crates.io-index"
179dependencies = [ 179dependencies = [
180 "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 180 "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
181 "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 181 "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
182] 182]
183 183
184[[package]] 184[[package]]
185name = "num-traits" 185name = "num-traits"
186version = "0.2.8" 186version = "0.2.9"
187source = "registry+https://github.com/rust-lang/crates.io-index" 187source = "registry+https://github.com/rust-lang/crates.io-index"
188dependencies = [ 188dependencies = [
189 "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 189 "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
190] 190]
191 191
192[[package]] 192[[package]]
193name = "num_cpus" 193name = "num_cpus"
194version = "1.11.0" 194version = "1.11.1"
195source = "registry+https://github.com/rust-lang/crates.io-index" 195source = "registry+https://github.com/rust-lang/crates.io-index"
196dependencies = [ 196dependencies = [
197 "hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 197 "hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
198 "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", 198 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
199] 199]
200 200
201[[package]] 201[[package]]
@@ -203,9 +203,9 @@ name = "pandoc_types"
203version = "0.2.0" 203version = "0.2.0"
204source = "registry+https://github.com/rust-lang/crates.io-index" 204source = "registry+https://github.com/rust-lang/crates.io-index"
205dependencies = [ 205dependencies = [
206 "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", 206 "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
207 "serde_derive 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", 207 "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
208 "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", 208 "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
209] 209]
210 210
211[[package]] 211[[package]]
@@ -217,20 +217,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
217name = "poseidoc" 217name = "poseidoc"
218version = "0.1.0" 218version = "0.1.0"
219dependencies = [ 219dependencies = [
220 "anyhow 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", 220 "anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
221 "clang 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", 221 "clang 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
222 "codemap 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 222 "codemap 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
223 "codemap-diagnostic 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 223 "codemap-diagnostic 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
224 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 224 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
225 "num_cpus 1.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 225 "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
226 "pandoc_types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 226 "pandoc_types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
227 "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 227 "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
228 "pretty_env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 228 "pretty_env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
229 "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", 229 "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
230 "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
231 "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
230 "shell-words 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 232 "shell-words 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
231 "structopt 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 233 "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
232 "thiserror 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 234 "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
233 "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", 235 "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
236 "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
234 "xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 237 "xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
235] 238]
236 239
@@ -249,14 +252,14 @@ name = "proc-macro-error"
249version = "0.2.6" 252version = "0.2.6"
250source = "registry+https://github.com/rust-lang/crates.io-index" 253source = "registry+https://github.com/rust-lang/crates.io-index"
251dependencies = [ 254dependencies = [
252 "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 255 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
253 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 256 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
254 "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 257 "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
255] 258]
256 259
257[[package]] 260[[package]]
258name = "proc-macro2" 261name = "proc-macro2"
259version = "1.0.3" 262version = "1.0.6"
260source = "registry+https://github.com/rust-lang/crates.io-index" 263source = "registry+https://github.com/rust-lang/crates.io-index"
261dependencies = [ 264dependencies = [
262 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 265 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -272,7 +275,7 @@ name = "quote"
272version = "1.0.2" 275version = "1.0.2"
273source = "registry+https://github.com/rust-lang/crates.io-index" 276source = "registry+https://github.com/rust-lang/crates.io-index"
274dependencies = [ 277dependencies = [
275 "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 278 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
276] 279]
277 280
278[[package]] 281[[package]]
@@ -298,32 +301,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
298 301
299[[package]] 302[[package]]
300name = "ryu" 303name = "ryu"
301version = "1.0.0" 304version = "1.0.2"
302source = "registry+https://github.com/rust-lang/crates.io-index" 305source = "registry+https://github.com/rust-lang/crates.io-index"
303 306
304[[package]] 307[[package]]
305name = "serde" 308name = "serde"
306version = "1.0.100" 309version = "1.0.102"
307source = "registry+https://github.com/rust-lang/crates.io-index" 310source = "registry+https://github.com/rust-lang/crates.io-index"
308 311
309[[package]] 312[[package]]
310name = "serde_derive" 313name = "serde_derive"
311version = "1.0.100" 314version = "1.0.102"
312source = "registry+https://github.com/rust-lang/crates.io-index" 315source = "registry+https://github.com/rust-lang/crates.io-index"
313dependencies = [ 316dependencies = [
314 "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 317 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
315 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 318 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
316 "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 319 "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
317] 320]
318 321
319[[package]] 322[[package]]
320name = "serde_json" 323name = "serde_json"
321version = "1.0.40" 324version = "1.0.41"
322source = "registry+https://github.com/rust-lang/crates.io-index" 325source = "registry+https://github.com/rust-lang/crates.io-index"
323dependencies = [ 326dependencies = [
324 "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", 327 "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
325 "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 328 "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
326 "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", 329 "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
327] 330]
328 331
329[[package]] 332[[package]]
@@ -338,31 +341,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
338 341
339[[package]] 342[[package]]
340name = "structopt" 343name = "structopt"
341version = "0.3.3" 344version = "0.3.4"
342source = "registry+https://github.com/rust-lang/crates.io-index" 345source = "registry+https://github.com/rust-lang/crates.io-index"
343dependencies = [ 346dependencies = [
344 "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", 347 "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
345 "structopt-derive 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 348 "structopt-derive 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
346] 349]
347 350
348[[package]] 351[[package]]
349name = "structopt-derive" 352name = "structopt-derive"
350version = "0.3.3" 353version = "0.3.4"
351source = "registry+https://github.com/rust-lang/crates.io-index" 354source = "registry+https://github.com/rust-lang/crates.io-index"
352dependencies = [ 355dependencies = [
353 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 356 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
354 "proc-macro-error 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", 357 "proc-macro-error 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
355 "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 358 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
356 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 359 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
357 "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 360 "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
358] 361]
359 362
360[[package]] 363[[package]]
361name = "syn" 364name = "syn"
362version = "1.0.5" 365version = "1.0.8"
363source = "registry+https://github.com/rust-lang/crates.io-index" 366source = "registry+https://github.com/rust-lang/crates.io-index"
364dependencies = [ 367dependencies = [
365 "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 368 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
366 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 369 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
367 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 370 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
368] 371]
@@ -385,20 +388,20 @@ dependencies = [
385 388
386[[package]] 389[[package]]
387name = "thiserror" 390name = "thiserror"
388version = "1.0.1" 391version = "1.0.5"
389source = "registry+https://github.com/rust-lang/crates.io-index" 392source = "registry+https://github.com/rust-lang/crates.io-index"
390dependencies = [ 393dependencies = [
391 "thiserror-impl 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 394 "thiserror-impl 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
392] 395]
393 396
394[[package]] 397[[package]]
395name = "thiserror-impl" 398name = "thiserror-impl"
396version = "1.0.0" 399version = "1.0.5"
397source = "registry+https://github.com/rust-lang/crates.io-index" 400source = "registry+https://github.com/rust-lang/crates.io-index"
398dependencies = [ 401dependencies = [
399 "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 402 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
400 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 403 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
401 "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 404 "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
402] 405]
403 406
404[[package]] 407[[package]]
@@ -414,7 +417,7 @@ name = "threadpool"
414version = "1.7.1" 417version = "1.7.1"
415source = "registry+https://github.com/rust-lang/crates.io-index" 418source = "registry+https://github.com/rust-lang/crates.io-index"
416dependencies = [ 419dependencies = [
417 "num_cpus 1.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 420 "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
418] 421]
419 422
420[[package]] 423[[package]]
@@ -422,14 +425,22 @@ name = "time"
422version = "0.1.42" 425version = "0.1.42"
423source = "registry+https://github.com/rust-lang/crates.io-index" 426source = "registry+https://github.com/rust-lang/crates.io-index"
424dependencies = [ 427dependencies = [
425 "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", 428 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
426 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", 429 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
427 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 430 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
428] 431]
429 432
430[[package]] 433[[package]]
434name = "toml"
435version = "0.5.5"
436source = "registry+https://github.com/rust-lang/crates.io-index"
437dependencies = [
438 "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
439]
440
441[[package]]
431name = "unicode-segmentation" 442name = "unicode-segmentation"
432version = "1.3.0" 443version = "1.6.0"
433source = "registry+https://github.com/rust-lang/crates.io-index" 444source = "registry+https://github.com/rust-lang/crates.io-index"
434 445
435[[package]] 446[[package]]
@@ -491,11 +502,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
491[metadata] 502[metadata]
492"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" 503"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
493"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" 504"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
494"checksum anyhow 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "aaf594cde167a6a4e715d4c8c3a71eb07e6b2c48b28014f9425bc8f7d8bdec11" 505"checksum anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "57114fc2a6cc374bce195d3482057c846e706d252ff3604363449695684d7a0d"
495"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" 506"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90"
496"checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" 507"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
497"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2" 508"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
498"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" 509"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
499"checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" 510"checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68"
500"checksum clang 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "edaa418fdc81a329f3c8258a4e8776f7d2c31682147c5bda1c5c37ab8e818114" 511"checksum clang 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "edaa418fdc81a329f3c8258a4e8776f7d2c31682147c5bda1c5c37ab8e818114"
501"checksum clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853" 512"checksum clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853"
@@ -509,39 +520,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
509"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" 520"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
510"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" 521"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
511"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 522"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
512"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" 523"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8"
513"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" 524"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
514"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" 525"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
515"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" 526"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"
516"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" 527"checksum num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "443c53b3c3531dfcbfa499d8893944db78474ad7a1d87fa2d94d1a2231693ac6"
517"checksum num_cpus 1.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "155394f924cdddf08149da25bfb932d226b4a593ca7468b08191ff6335941af5" 528"checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72"
518"checksum pandoc_types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29869c4f0ed84c2514105047415ff220679d7dbe566982c32f60a5c330cb77ed" 529"checksum pandoc_types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29869c4f0ed84c2514105047415ff220679d7dbe566982c32f60a5c330cb77ed"
519"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 530"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
520"checksum pretty_env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "717ee476b1690853d222af4634056d830b5197ffd747726a9a1eee6da9f49074" 531"checksum pretty_env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "717ee476b1690853d222af4634056d830b5197ffd747726a9a1eee6da9f49074"
521"checksum proc-macro-error 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aeccfe4d5d8ea175d5f0e4a2ad0637e0f4121d63bd99d356fb1f39ab2e7c6097" 532"checksum proc-macro-error 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aeccfe4d5d8ea175d5f0e4a2ad0637e0f4121d63bd99d356fb1f39ab2e7c6097"
522"checksum proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" 533"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
523"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" 534"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
524"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" 535"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
525"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" 536"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
526"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" 537"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd"
527"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" 538"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716"
528"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" 539"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8"
529"checksum serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)" = "f4473e8506b213730ff2061073b48fa51dcc66349219e2e7c5608f0296a1d95a" 540"checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0"
530"checksum serde_derive 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)" = "11e410fde43e157d789fc290d26bc940778ad0fdd47836426fbac36573710dbb" 541"checksum serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "ca13fc1a832f793322228923fbb3aba9f3f44444898f835d31ad1b74fa0a2bf8"
531"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" 542"checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2"
532"checksum shell-words 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "39acde55a154c4cd3ae048ac78cc21c25f3a0145e44111b523279113dce0d94a" 543"checksum shell-words 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "39acde55a154c4cd3ae048ac78cc21c25f3a0145e44111b523279113dce0d94a"
533"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 544"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
534"checksum structopt 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4f66a4c0ddf7aee4677995697366de0749b0139057342eccbb609b12d0affc" 545"checksum structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c167b61c7d4c126927f5346a4327ce20abf8a186b8041bbeb1ce49e5db49587b"
535"checksum structopt-derive 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8fe0c13e476b4e21ff7f5c4ace3818b6d7bdc16897c31c73862471bc1663acae" 546"checksum structopt-derive 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "519621841414165d2ad0d4c92be8f41844203f2b67e245f9345a5a12d40c69d7"
536"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" 547"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92"
537"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" 548"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e"
538"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 549"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
539"checksum thiserror 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76a6728729f99559e9ec7e39848ea39623849aa1d7d3bb99b30ec349a2ffc730" 550"checksum thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f9fb62ff737e573b1e677459bea6fd023cd5d6e868c3242d3cdf3ef2f0554824"
540"checksum thiserror-impl 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e9d53f5a0d2bd66d1d841e69a4beb74a226216b3f158ff0c534578f76e7beac9" 551"checksum thiserror-impl 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "24069c0ba08aab54289d6a25f5036d94afc61e1538bbc42ae5501df141c9027d"
541"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" 552"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
542"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" 553"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865"
543"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" 554"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
544"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" 555"checksum toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "01d1404644c8b12b16bfcffa4322403a91a451584daaaa7c28d3152e6cbc98cf"
556"checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
545"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" 557"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20"
546"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" 558"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
547"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" 559"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
diff --git a/Cargo.toml b/Cargo.toml
index 17f23da..54e8670 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,9 +16,12 @@ num_cpus = "1"
16pandoc_types = "0.2" 16pandoc_types = "0.2"
17percent-encoding = "2" 17percent-encoding = "2"
18pretty_env_logger = "0.3" 18pretty_env_logger = "0.3"
19serde = "1"
20serde_derive = "1"
19serde_json = "1" 21serde_json = "1"
20shell-words = "0.1" 22shell-words = "0.1"
21structopt = "0.3" 23structopt = "0.3"
22thiserror = "1" 24thiserror = "1"
23threadpool = "1" 25threadpool = "1"
26toml = "0.5"
24xml-rs = "0.8" 27xml-rs = "0.8"
diff --git a/res/sample-markdown-project-1/poseidoc.toml b/res/sample-markdown-project-1/poseidoc.toml
new file mode 100644
index 0000000..fe24995
--- /dev/null
+++ b/res/sample-markdown-project-1/poseidoc.toml
@@ -0,0 +1 @@
name = "Sample Markdown Project"
diff --git a/src/cli.rs b/src/cli.rs
index e106de7..0a883af 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -1,5 +1,9 @@
1use crate::config::Config;
2
1use structopt::StructOpt; 3use structopt::StructOpt;
2 4
5use std::path::PathBuf;
6
3#[derive(Debug, Clone, StructOpt)] 7#[derive(Debug, Clone, StructOpt)]
4pub(crate) struct Cli { 8pub(crate) struct Cli {
5 #[structopt(long, short, parse(from_occurrences))] 9 #[structopt(long, short, parse(from_occurrences))]
@@ -8,11 +12,27 @@ pub(crate) struct Cli {
8 #[structopt(long, number_of_values = 1, parse(try_from_str = shell_words::split))] 12 #[structopt(long, number_of_values = 1, parse(try_from_str = shell_words::split))]
9 pub(crate) extra_arg: Vec<Vec<String>>, 13 pub(crate) extra_arg: Vec<Vec<String>>,
10 14
15 #[structopt(long, short = "C", default_value = ".")]
16 pub(crate) directory: PathBuf,
17
11 #[structopt(subcommand)] 18 #[structopt(subcommand)]
12 pub(crate) command: Command, 19 pub(crate) command: Command,
20
21 #[structopt(flatten)]
22 pub(crate) common_options: Config,
13} 23}
14 24
15#[derive(Debug, Clone, StructOpt)] 25#[derive(Debug, Clone, StructOpt)]
16pub(crate) enum Command { 26pub(crate) enum Command {
17 Generate { file: String }, 27 Generate { file: String },
28 Config {
29 #[structopt(subcommand)]
30 command: ConfigCommand,
31 }
32}
33
34#[derive(Debug, Clone, StructOpt)]
35pub(crate) enum ConfigCommand {
36 Default,
37 Show,
18} 38}
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..4463479
--- /dev/null
+++ b/src/config.rs
@@ -0,0 +1,107 @@
1use anyhow::{anyhow, Context, Result};
2use codemap::CodeMap;
3use codemap_diagnostic::Diagnostic;
4use serde_derive::{Deserialize, Serialize};
5use structopt::StructOpt;
6use thiserror::Error;
7
8use std::path::{Path, PathBuf};
9use std::sync::Arc;
10
11pub(super) const DEFAULT_PROJECT_CONFIGURATION_FILE_NAME: &str = "poseidoc.toml";
12
13#[derive(Debug, Clone, StructOpt, Deserialize, Serialize)]
14#[structopt(rename_all = "kebab-case")]
15#[serde(rename_all = "kebab-case", default)]
16pub(crate) struct Config {
17 #[structopt(skip)]
18 pub(crate) name: String,
19 #[structopt(long, default_value = ".")]
20 pub(crate) compile_commands_location: PathBuf,
21 #[structopt(skip = vec![])]
22 pub(crate) extra_clang_args: Vec<String>,
23}
24
25impl Default for Config {
26 fn default() -> Self {
27 Config {
28 name: "My Project".into(),
29 compile_commands_location: PathBuf::from(r"."),
30 extra_clang_args: Vec::new(),
31 }
32 }
33}
34
35pub(super) fn load_config(location: impl AsRef<Path>, codemap: &mut CodeMap) -> Result<Config> {
36 let location = location.as_ref();
37
38 let final_path = if location.is_dir() {
39 location.join(DEFAULT_PROJECT_CONFIGURATION_FILE_NAME)
40 } else if !location.exists() {
41 return Err(anyhow!("File {:?} does not exists", location))
42 .with_context(|| format!("Failed to open project configuration: {:?}", location));
43 } else {
44 location.to_owned()
45 };
46
47 let config_str =
48 std::fs::read_to_string(&final_path).map_err(|err| ConfigLoadError::IoError {
49 file_name: final_path.clone(),
50 source: err,
51 })?;
52 Ok(
53 toml::from_str(&config_str).map_err(|err| ConfigLoadError::TomlDeserialzation {
54 file: codemap.add_file(final_path.to_string_lossy().into(), config_str),
55 source: err,
56 })?,
57 )
58}
59
60#[derive(Debug, Error)]
61#[error("Error loading project configuration")]
62pub(crate) enum ConfigLoadError {
63 #[error("Failed to read project configuration: {:?}", file_name)]
64 IoError {
65 file_name: PathBuf,
66 source: std::io::Error,
67 },
68 #[error("Failed to parse project configuration: {:?}", file.name())]
69 TomlDeserialzation {
70 file: Arc<codemap::File>,
71 source: toml::de::Error,
72 },
73}
74
75impl From<&ConfigLoadError> for Diagnostic {
76 fn from(err: &ConfigLoadError) -> Diagnostic {
77 use codemap_diagnostic::{Level, SpanLabel, SpanStyle};
78 use std::convert::TryInto;
79
80 let message = err.to_string();
81
82 let spans = match err {
83 ConfigLoadError::IoError { .. } => vec![],
84 ConfigLoadError::TomlDeserialzation { file, source, .. } => {
85 if let Some((line, col)) = source.line_col() {
86 let line_span = file.line_span(line);
87 let col = col.try_into().unwrap();
88 let span = line_span.subspan(col, col);
89 vec![SpanLabel {
90 span,
91 label: None,
92 style: SpanStyle::Primary,
93 }]
94 } else {
95 vec![]
96 }
97 }
98 };
99
100 Diagnostic {
101 level: Level::Error,
102 message,
103 code: None,
104 spans,
105 }
106 }
107}
diff --git a/src/main.rs b/src/main.rs
index e1d4752..503688e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,6 @@
1//mod doxygen; 1//mod doxygen;
2mod cli; 2mod cli;
3mod config;
3mod entities; 4mod entities;
4mod generator; 5mod generator;
5mod pandoc; 6mod pandoc;
@@ -8,14 +9,63 @@ mod parsing;
8#[macro_use] 9#[macro_use]
9extern crate log; 10extern crate log;
10 11
11use cli::Command; 12use cli::{Command, ConfigCommand};
12use generator::generate; 13use generator::generate;
13use parsing::parse_file; 14use parsing::parse_file;
14 15
15use anyhow::Result; 16use anyhow::{Context, Result};
17use codemap::CodeMap;
18use codemap_diagnostic::{Diagnostic, Emitter, Level};
16use structopt::StructOpt; 19use structopt::StructOpt;
17 20
18fn main() -> Result<()> { 21fn into_diagnostic(err: &anyhow::Error) -> Diagnostic {
22 if let Some(err) = err.downcast_ref::<config::ConfigLoadError>() {
23 err.into()
24 } else {
25 Diagnostic {
26 level: Level::Error,
27 message: err.to_string(),
28 code: None,
29 spans: vec![],
30 }
31 }
32}
33
34fn main() {
35 let mut codemap = CodeMap::new();
36
37 match start(&mut codemap) {
38 Ok(()) => {}
39 Err(err) => {
40 let mut emitter =
41 Emitter::stderr(codemap_diagnostic::ColorConfig::Auto, Some(&codemap));
42
43 let mut diagnostics = Vec::new();
44 diagnostics.push(into_diagnostic(&err));
45
46 if let Some(mut source) = err.source() {
47 diagnostics.push(Diagnostic {
48 level: Level::Note,
49 message: format!("Caused by: {}", source),
50 code: None,
51 spans: vec![],
52 });
53 while let Some(source2) = source.source() {
54 source = source2;
55 diagnostics.push(Diagnostic {
56 level: Level::Note,
57 message: format!("Caused by: {}", source),
58 code: None,
59 spans: vec![],
60 });
61 }
62 }
63 emitter.emit(&diagnostics);
64 }
65 }
66}
67
68fn start(codemap: &mut CodeMap) -> Result<()> {
19 let cli = cli::Cli::from_args(); 69 let cli = cli::Cli::from_args();
20 pretty_env_logger::formatted_builder() 70 pretty_env_logger::formatted_builder()
21 .filter( 71 .filter(
@@ -30,6 +80,9 @@ fn main() -> Result<()> {
30 ) 80 )
31 .try_init()?; 81 .try_init()?;
32 82
83 std::env::set_current_dir(&cli.directory)
84 .with_context(|| format!("Cannot change current directory to: {:?}", cli.directory))?;
85
33 match cli.command { 86 match cli.command {
34 Command::Generate { file } => { 87 Command::Generate { file } => {
35 let extra_args = cli.extra_arg.iter().flatten().map(AsRef::as_ref).collect(); 88 let extra_args = cli.extra_arg.iter().flatten().map(AsRef::as_ref).collect();
@@ -38,6 +91,19 @@ fn main() -> Result<()> {
38 let base_output_dir = std::path::Path::new("doc"); 91 let base_output_dir = std::path::Path::new("doc");
39 generate(&base_output_dir, manager)?; 92 generate(&base_output_dir, manager)?;
40 } 93 }
94 Command::Config {
95 command: ConfigCommand::Default,
96 } => {
97 print!("{}", toml::to_string_pretty(&config::Config::default())?);
98 }
99 Command::Config {
100 command: ConfigCommand::Show,
101 } => {
102 print!(
103 "{}",
104 toml::to_string_pretty(&config::load_config(".", codemap)?)?
105 );
106 }
41 } 107 }
42 108
43 Ok(()) 109 Ok(())