From: Kostya Shishkov Date: Sat, 30 Nov 2019 10:54:00 +0000 (+0100) Subject: support some options X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=659b64294d7bce34c7c5a939c5cbe78d8a87ff75;p=nihav-player.git support some options --- diff --git a/src/main.rs b/src/main.rs index e0c9340..31642ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -311,7 +311,20 @@ println!("reinit scaler!"); }) } -fn play_file(name: &str) { +fn play_file(args: Vec) { + + let mut cur_arg: usize = 1; + let mut decode_audio = true; + while (cur_arg < args.len()) && args[cur_arg].starts_with('-') { + match args[cur_arg].as_str() { + "--" => { break; }, + "-an" => { decode_audio = false; }, + _ => { println!("unknown option {}", args[cur_arg]); return; }, + } + cur_arg += 1; + } + let name = args[cur_arg].as_str(); + let path = Path::new(name); let mut file = File::open(path).unwrap(); let dmx_fact; @@ -379,7 +392,7 @@ fn play_file(name: &str) { tb_den = tbd; } } else if info.is_audio() { - if audio_dec.is_none() { + if audio_dec.is_none() && decode_audio { if decfunc.is_none() { println!("no audio decoder for {} found!", info.get_name()); } else { @@ -572,15 +585,14 @@ fn play_file(name: &str) { } fn main() { - let args: Vec<_> = env::args().collect(); + let args: Vec = env::args().collect(); if args.len() == 1 { println!("usage: nihav-player input"); return; } - let name = args[1].as_str(); - play_file(name); + play_file(args); sdl::quit(); }