From d123fa51cf019906d9b66838bdbae9def5295522 Mon Sep 17 00:00:00 2001 From: azazelm3dj3d <56496067+azazelm3dj3d@users.noreply.github.com> Date: Sat, 13 May 2023 23:14:43 -0500 Subject: [PATCH 1/2] Fix deku dep --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index bb35afc..3bb7f63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,6 @@ exclude = ["examples/**", "axmldecoder-printer/**"] [dependencies] byteorder = "1.4.3" -deku = "~0.15" +deku = "~0.16" indexmap = "1.9.2" thiserror = "1.0.37" From a5f84262562625748c62219ede20d601de0bf36c Mon Sep 17 00:00:00 2001 From: azazelm3dj3d <56496067+azazelm3dj3d@users.noreply.github.com> Date: Sun, 14 May 2023 00:09:47 -0500 Subject: [PATCH 2/2] Can now run the axmldecoder-printer binary against all examples at once --- axmldecoder-printer/src/main.rs | 37 ++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/axmldecoder-printer/src/main.rs b/axmldecoder-printer/src/main.rs index 8917710..99ee1ce 100644 --- a/axmldecoder-printer/src/main.rs +++ b/axmldecoder-printer/src/main.rs @@ -1,20 +1,37 @@ +use std::{fs, env}; use anyhow::Result; use axmldecoder::{Cdata, Element, Node}; fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); - let fname = args.get(1).unwrap(); + let args: Vec = env::args().collect(); - let f = std::fs::read(fname)?; - let xml = axmldecoder::parse(&f)?; + if args.len() <= 1 { + for path in fs::read_dir("../examples").unwrap() { + let f = std::fs::read(path?.path())?; + let xml = axmldecoder::parse(&f)?; + + let root = xml.get_root().as_ref().unwrap(); + let mut s = String::new(); + s.push_str("\n"); + format_xml(&root, 0_usize, &mut s); + + let s = s.trim().to_string(); + println!("{}", s); + } + } else { + let fname = args.get(1).unwrap(); - let root = xml.get_root().as_ref().unwrap(); - let mut s = String::new(); - s.push_str("\n"); - format_xml(&root, 0_usize, &mut s); + let f = std::fs::read(fname)?; + let xml = axmldecoder::parse(&f)?; - let s = s.trim().to_string(); - println!("{}", s); + let root = xml.get_root().as_ref().unwrap(); + let mut s = String::new(); + s.push_str("\n"); + format_xml(&root, 0_usize, &mut s); + + let s = s.trim().to_string(); + println!("{}", s); + } Ok(()) }