diff --git a/src/main.rs b/src/main.rs index 8777449d..aba4856c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -321,16 +321,13 @@ fn parse_opts_into_struct( .init() .unwrap(); - let mut opts = if let Some(x) = matches.value_of("optimization") { - if let Ok(opt) = x.parse::() { - Options::from_preset(opt) - } else { - unreachable!() - } - } else { - Options::default() + let level = match matches.value_of("optimization") { + Some(x) => x.parse::().unwrap(), + None => 2, }; + let mut opts = Options::from_preset(level); + if let Some(x) = matches.value_of("interlace") { opts.interlace = x.parse::().ok(); } @@ -494,6 +491,17 @@ fn parse_opts_into_struct( } } + if level > 3 { + match opts.deflate { + Deflaters::Zlib { .. } => {} + _ => { + warn!( + "Level 4 and above are equivalent to level 3 for compressors other than zlib" + ); + } + } + } + if let Some(x) = matches.value_of("threads") { let threads = x.parse::().unwrap();