Add --ziwi option
This commit is contained in:
parent
8a5a3ab69e
commit
be608ea876
2 changed files with 15 additions and 0 deletions
11
src/cli.rs
11
src/cli.rs
|
|
@ -340,6 +340,17 @@ speed up compression for large files. This option requires '--zopfli' to be set.
|
||||||
.value_parser(value_parser!(NonZeroU64))
|
.value_parser(value_parser!(NonZeroU64))
|
||||||
.requires("zopfli"),
|
.requires("zopfli"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("iterations-without-improvement")
|
||||||
|
.hide_short_help(true)
|
||||||
|
.long_help("\
|
||||||
|
Stop Zopfli compression after this number of iterations without improvement. Use this in \
|
||||||
|
conjunction with a high value for '--zi' to achieve better compression in reasonable time.")
|
||||||
|
.long("ziwi")
|
||||||
|
.value_name("iterations")
|
||||||
|
.value_parser(value_parser!(NonZeroU64))
|
||||||
|
.requires("zopfli"),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("timeout")
|
Arg::new("timeout")
|
||||||
.help("Maximum amount of time to spend on optimizations")
|
.help("Maximum amount of time to spend on optimizations")
|
||||||
|
|
|
||||||
|
|
@ -334,8 +334,12 @@ fn parse_opts_into_struct(
|
||||||
#[cfg(feature = "zopfli")]
|
#[cfg(feature = "zopfli")]
|
||||||
if matches.get_flag("zopfli") {
|
if matches.get_flag("zopfli") {
|
||||||
let iteration_count = *matches.get_one::<NonZeroU64>("iterations").unwrap();
|
let iteration_count = *matches.get_one::<NonZeroU64>("iterations").unwrap();
|
||||||
|
let iterations_without_improvement = *matches
|
||||||
|
.get_one::<NonZeroU64>("iterations-without-improvement")
|
||||||
|
.unwrap_or(&NonZeroU64::MAX);
|
||||||
opts.deflater = Deflater::Zopfli(ZopfliOptions {
|
opts.deflater = Deflater::Zopfli(ZopfliOptions {
|
||||||
iteration_count,
|
iteration_count,
|
||||||
|
iterations_without_improvement,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue