summaryrefslogtreecommitdiff
path: root/c2enc
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2022-07-23 11:32:42 +0300
committerYuval Adam <_@yuv.al>2022-07-23 11:32:42 +0300
commitefce6b6218d589094fee9aa42c3400c4af622edb (patch)
tree040daf06a3a22276a00c921832de42a211e4b6b5 /c2enc
parent44aa0598cbfc5d0f8b4dbff614f5999c942f9767 (diff)
Add c2enc args
Diffstat (limited to 'c2enc')
-rw-r--r--c2enc/src/main.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/c2enc/src/main.rs b/c2enc/src/main.rs
index ec57ed5..e0181f3 100644
--- a/c2enc/src/main.rs
+++ b/c2enc/src/main.rs
@@ -7,9 +7,22 @@ use std::io::prelude::*;
use std::io::Cursor;
use std::path::Path;
+struct Cli {
+ in_path: std::path::PathBuf,
+ out_path: std::path::PathBuf,
+}
+
fn main() {
- let path = Path::new("../../codec2/wav/cross.wav");
- let mut file = File::open(&path).unwrap();
+ let in_path_arg = std::env::args().nth(1).expect("no input path given");
+ let out_path_arg = std::env::args().nth(2).expect("no output path given");
+
+ let args = Cli {
+ in_path: std::path::PathBuf::from(in_path_arg),
+ out_path: std::path::PathBuf::from(out_path_arg),
+ };
+
+ let in_path = Path::new(&args.in_path);
+ let mut file = File::open(&in_path).unwrap();
let mut buf = Vec::new();
file.read_to_end(&mut buf).unwrap();
@@ -30,6 +43,6 @@ fn main() {
allbits.extend(bits);
}
- let mut file = File::create("out.c2").unwrap();
+ let mut file = File::create(&args.out_path).unwrap();
file.write_all(&allbits).unwrap();
}