Skip to content

Commit

Permalink
Merge pull request #10 from azazelm3dj3d/master
Browse files Browse the repository at this point in the history
Fix deku dependency and add the option to iterate over the entire examples directory at once
  • Loading branch information
Ayrx authored May 14, 2023
2 parents 425e038 + a5f8426 commit 349d544
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
37 changes: 27 additions & 10 deletions axmldecoder-printer/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
use std::{fs, env};
use anyhow::Result;
use axmldecoder::{Cdata, Element, Node};

fn main() -> Result<()> {
let args: Vec<String> = std::env::args().collect();
let fname = args.get(1).unwrap();
let args: Vec<String> = 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("<?xml version=\"1.0\" encoding=\"utf-8\"?>\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("<?xml version=\"1.0\" encoding=\"utf-8\"?>\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("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
format_xml(&root, 0_usize, &mut s);

let s = s.trim().to_string();
println!("{}", s);
}

Ok(())
}
Expand Down

0 comments on commit 349d544

Please sign in to comment.