implement --fast and --slow

This commit is contained in:
figsoda 2023-03-19 15:04:27 -04:00
parent e0391a872b
commit f21883170b
2 changed files with 20 additions and 2 deletions

View File

@ -61,8 +61,18 @@ pub enum Subcommand {
output: PathBuf,
/// Compression level, applied to all formats
#[arg(short, long)]
#[arg(short, long, group = "compression-level")]
level: Option<i16>,
/// Fastest compression level possible,
/// conflicts with --level and --slow
#[arg(long, group = "compression-level")]
fast: bool,
/// Slowest (and best) compression level possible,
/// conflicts with --level and --fast
#[arg(long, group = "compression-level")]
slow: bool,
},
/// Decompresses one or more files, optionally into another folder
#[command(visible_alias = "d")]

View File

@ -45,6 +45,8 @@ pub fn run(
files,
output: output_path,
level,
fast,
slow,
} => {
// After cleaning, if there are no input files left, exit
if files.is_empty() {
@ -81,7 +83,13 @@ pub fn run(
args.quiet,
question_policy,
file_visibility_policy,
level,
if fast {
Some(0)
} else if slow {
Some(i16::MAX)
} else {
level
},
);
if let Ok(true) = compress_result {