Add "max" level alias; more level warnings
This commit is contained in:
parent
cffc3ce991
commit
5536e5acd2
2 changed files with 27 additions and 15 deletions
10
src/lib.rs
10
src/lib.rs
|
|
@ -206,10 +206,18 @@ impl Options {
|
|||
opts.apply_preset_4()
|
||||
}
|
||||
5 => opts.apply_preset_5(),
|
||||
_ => opts.apply_preset_6(),
|
||||
6 => opts.apply_preset_6(),
|
||||
_ => {
|
||||
warn!("Level 7 and above don't exist yet and are identical to level 6");
|
||||
opts.apply_preset_6()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn max_compression() -> Options {
|
||||
Options::from_preset(6)
|
||||
}
|
||||
|
||||
// The following methods make assumptions that they are operating
|
||||
// on an `Options` struct generated by the `default` method.
|
||||
fn apply_preset_0(mut self) -> Self {
|
||||
|
|
|
|||
32
src/main.rs
32
src/main.rs
|
|
@ -52,7 +52,8 @@ fn main() {
|
|||
.possible_value("3")
|
||||
.possible_value("4")
|
||||
.possible_value("5")
|
||||
.possible_value("6"))
|
||||
.possible_value("6")
|
||||
.possible_value("max"))
|
||||
.arg(Arg::with_name("backup")
|
||||
.help("Back up modified files")
|
||||
.short("b")
|
||||
|
|
@ -227,13 +228,14 @@ fn main() {
|
|||
}
|
||||
}))
|
||||
.after_help("Optimization levels:
|
||||
-o 0 => --zc 3 --nz (0 or 1 trials)
|
||||
-o 1 => --zc 9 (1 trial, determined heuristically)
|
||||
-o 2 => --zc 9 --zs 0-3 -f 0,5 (8 trials)
|
||||
-o 3 => --zc 9 --zs 0-3 -f 0-5 (24 trials)
|
||||
-o 4 => (deprecated; same as `-o 3`)
|
||||
-o 5 => --zc 3-9 --zs 0-3 -f 0-5 (96 trials)
|
||||
-o 6 => --zc 1-9 --zs 0-3 -f 0-5 (180 trials)
|
||||
-o 0 => --zc 3 --nz (0 or 1 trials)
|
||||
-o 1 => --zc 9 (1 trial, determined heuristically)
|
||||
-o 2 => --zc 9 --zs 0-3 -f 0,5 (8 trials)
|
||||
-o 3 => --zc 9 --zs 0-3 -f 0-5 (24 trials)
|
||||
-o 4 => (deprecated; same as `-o 3`)
|
||||
-o 5 => --zc 3-9 --zs 0-3 -f 0-5 (96 trials)
|
||||
-o 6 => --zc 1-9 --zs 0-3 -f 0-5 (180 trials)
|
||||
-o max => (alias for the max compression, currently same as -o 6)
|
||||
|
||||
Manually specifying a compression option (zc, zs, etc.) will override the optimization preset,
|
||||
regardless of the order you write the arguments.")
|
||||
|
|
@ -321,13 +323,15 @@ fn parse_opts_into_struct(
|
|||
.init()
|
||||
.unwrap();
|
||||
|
||||
let level = match matches.value_of("optimization") {
|
||||
Some(x) => x.parse::<u8>().unwrap(),
|
||||
None => 2,
|
||||
let (explicit_level, mut opts) = match matches.value_of("optimization") {
|
||||
None => (None, Options::default()),
|
||||
Some("max") => (None, Options::max_compression()),
|
||||
Some(level) => {
|
||||
let level = level.parse::<u8>().unwrap();
|
||||
(Some(level), Options::from_preset(level))
|
||||
}
|
||||
};
|
||||
|
||||
let mut opts = Options::from_preset(level);
|
||||
|
||||
if let Some(x) = matches.value_of("interlace") {
|
||||
opts.interlace = x.parse::<u8>().ok();
|
||||
}
|
||||
|
|
@ -491,7 +495,7 @@ fn parse_opts_into_struct(
|
|||
}
|
||||
}
|
||||
|
||||
if level > 3 {
|
||||
if explicit_level > Some(3) {
|
||||
match opts.deflate {
|
||||
Deflaters::Zlib { .. } => {}
|
||||
_ => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue