diff --git a/.gitignore b/.gitignore index cefc28c..5d31382 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.swp main target +output diff --git a/Cargo.lock b/Cargo.lock index 6c6f01e..63bc976 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,14 +3,37 @@ version = 3 [[package]] -name = "json" -version = "0.12.4" +name = "itoa" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "serde" +version = "1.0.160" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" + +[[package]] +name = "serde_json" +version = "1.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +dependencies = [ + "itoa", + "ryu", + "serde", +] [[package]] name = "trello-to-markdown" version = "0.1.0" dependencies = [ - "json", + "serde_json", ] diff --git a/Cargo.toml b/Cargo.toml index 5f2d3b4..06a423b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,5 @@ name = "trello-to-markdown" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -json = "0.12.4" +serde_json = "1.0.96" diff --git a/output/.gitkeep b/output/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/main.rs b/src/main.rs index e2e9140..f5c055e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,22 @@ use std::fs; +use serde_json::Value; fn main(){ - let data = fs::read_to_string("boards/coding.json").expect("unable to read file"); - let parsed = json::parse(&data.to_string()).unwrap(); + let json_string = fs::read_to_string("boards/coding.json").expect("unable to read file"); + let output_dir = "output"; + fs::create_dir(output_dir).expect("uable to create dir"); - println!("{}", parsed["id"]); + let json_data: Value = serde_json::from_str(&json_string).unwrap(); + + + let board_dir = output_dir.to_owned() + "/" + json_data["name"].as_str().unwrap(); + fs::create_dir(&board_dir).expect("unable to create dir"); + + if let Value::Array(lists) = &json_data["lists"]{ + // Iterate over the elements in the array + for list in lists { + fs::create_dir(board_dir.clone() + "/" + list["name"].as_str().unwrap()).expect("unable to create dir"); + //println!("{}", list["name"].as_str().unwrap()); + } + } }