aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index ea89b02..a7f1f9d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,7 @@
1#![feature(rustc_macro)]
2#[macro_use] extern crate serde_derive;
3extern crate serde_json;
4
1extern crate regex; 5extern crate regex;
2extern crate yaml_rust; 6extern crate yaml_rust;
3 7
@@ -21,7 +25,9 @@ mod tiles;
21 25
22fn main() { 26fn main() {
23 let raw_files = env::var("RAW_FILES").unwrap_or("characters".into()); 27 let raw_files = env::var("RAW_FILES").unwrap_or("characters".into());
28 let out_files = env::var("OUT").unwrap_or("json".into());
24 let base_path = Path::new(&raw_files); 29 let base_path = Path::new(&raw_files);
30 let out_path = Path::new(&out_files);
25 31
26 32
27 for entry in WalkDir::new(base_path).min_depth(1).into_iter().filter_map(|e| e.ok()) { 33 for entry in WalkDir::new(base_path).min_depth(1).into_iter().filter_map(|e| e.ok()) {
@@ -36,6 +42,10 @@ fn main() {
36 42
37 let mut char = Character::new(); 43 let mut char = Character::new();
38 char.parse(&buf); 44 char.parse(&buf);
39 println!("{:?}", char); 45
46 let json = serde_json::to_string(&char).unwrap();
47
48 let mut o = File::create(out_path.join(entry.file_name())).unwrap();
49 o.write_all(json.as_bytes()).unwrap();
40 } 50 }
41} 51}