diff --git a/src/main.rs b/src/main.rs index 23cad86..f3375c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,10 +17,8 @@ fn main() { let mut opts = Options::new(); - opts.optflag("c", "", "create file"); - opts.optflag("x", "", "extract file"); - opts.optopt("i", "", "input file", "NAME"); - opts.optopt("o", "", "output file", "NAME"); + opts.optflag("c", "", "Compress file"); + opts.optflag("x", "", "Extract file"); let matches = match opts.parse(&args[1..]) { Ok(m) => { m } @@ -28,14 +26,14 @@ fn main() { }; if matches.opt_present("c") { - let input = matches.opt_str("i").unwrap(); - let output = matches.opt_str("o").unwrap(); + let input = &matches.free[0]; + let output = &matches.free[1]; create(&input, &output); } else if matches.opt_present("x") { - let input = matches.opt_str("i").unwrap(); - let output = matches.opt_str("o").unwrap(); + let input = &matches.free[0]; + let output = &matches.free[1]; extract(&input, &output) } @@ -59,11 +57,11 @@ fn create(input: &String, output: &String) { } } - let mut out : Vec = vec![]; + let mut index : Vec = vec![]; - out.write_i32::(i).unwrap(); + index.write_i32::(i).unwrap(); - output_file.write_all(&out).unwrap(); + output_file.write_all(&index).unwrap(); } }