This commit is contained in:
Robin Appelman 2022-04-18 13:15:07 +02:00
commit ada8c26125
2 changed files with 16 additions and 9 deletions

View file

@ -33,6 +33,7 @@ console_error_panic_hook = { version = "0.1.6", optional = true }
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
wee_alloc = { version = "0.4.5", optional = true }
pretty_assertions = "1.2.1"
clap = { version = "3.1.9", features = ["derive"] }
[dev-dependencies]
wasm-bindgen-test = "0.3.13"

View file

@ -1,15 +1,21 @@
use clap::Parser;
use democutter::cut;
use std::env;
use std::fs;
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Args {
/// Path to the source demo
path: String,
/// Start tick
start: u32,
/// End tick
end: Option<u32>,
}
fn main() {
let args: Vec<_> = env::args().collect();
if args.len() < 2 {
println!("1 argument required");
return;
}
let path = args[1].clone();
let file = fs::read(path).unwrap();
let output = cut(&file, 30000, 50000);
let args = Args::parse();
let file = fs::read(&args.path).unwrap();
let output = cut(&file, args.start, args.end.unwrap_or(u32::MAX));
fs::write("out.dem", output).unwrap();
}