got board and lists to create dirs

main
Matthew Huntington 3 years ago
parent 1a73809e03
commit 1a612f0fb3

1
.gitignore vendored

@ -1,3 +1,4 @@
*.swp *.swp
main main
target target
output

31
Cargo.lock generated

@ -3,14 +3,37 @@
version = 3 version = 3
[[package]] [[package]]
name = "json" name = "itoa"
version = "0.12.4" version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" 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]] [[package]]
name = "trello-to-markdown" name = "trello-to-markdown"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"json", "serde_json",
] ]

@ -3,7 +3,5 @@ name = "trello-to-markdown"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
json = "0.12.4" serde_json = "1.0.96"

@ -1,8 +1,22 @@
use std::fs; use std::fs;
use serde_json::Value;
fn main(){ fn main(){
let data = fs::read_to_string("boards/coding.json").expect("unable to read file"); let json_string = fs::read_to_string("boards/coding.json").expect("unable to read file");
let parsed = json::parse(&data.to_string()).unwrap(); 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());
}
}
} }

Loading…
Cancel
Save