1use dune_raw::{Format, Rawfile};
5
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let mut args = std::env::args().skip(1);
8 let (Some(input), Some(output), Some(fmt)) = (args.next(), args.next(), args.next()) else {
9 return Err("usage: recode <in.raw> <out.raw> ascii|binary".into());
10 };
11 let format = match fmt.as_str() {
12 "ascii" => Format::Ascii,
13 "binary" => Format::Binary,
14 other => return Err(format!("unknown format {other:?}").into()),
15 };
16 let raw = Rawfile::read_from(&input)?;
17 for w in &raw.warnings {
18 eprintln!("warning: {w}");
19 }
20 let mut out = std::fs::File::create(&output)?;
21 raw.write(&mut out, format)?;
22 Ok(())
23}