use crate::error::{Error, Result};
pub async fn run(args: Vec<String>) -> Result<()> {
let mut forwarded = Vec::with_capacity(args.len() + 1);
forwarded.push("xml-disassembler".to_string());
forwarded.extend(args);
crate::xml::cli::run(forwarded)
.await
.map_err(|e| Error::Xml(e.to_string()))
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn run_forwards_args_and_succeeds_for_valid_disassemble() {
let tmp = tempfile::tempdir().unwrap();
let xml_path = tmp.path().join("sample.xml");
std::fs::write(
&xml_path,
r#"<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns="http://example.com">
<child><name>one</name></child>
<child><name>two</name></child>
</Root>"#,
)
.unwrap();
run(vec![
"disassemble".to_string(),
xml_path.to_string_lossy().to_string(),
])
.await
.unwrap();
assert!(tmp.path().join("sample").exists());
}
#[tokio::test]
async fn run_propagates_unknown_subcommand_as_ok() {
run(vec!["definitely-not-a-real-subcommand".to_string()])
.await
.unwrap();
}
}