From f21883170b05ed93a900153439c01a6706c2da48 Mon Sep 17 00:00:00 2001 From: figsoda Date: Sun, 19 Mar 2023 15:04:27 -0400 Subject: [PATCH] implement `--fast` and `--slow` --- src/cli/args.rs | 12 +++++++++++- src/commands/mod.rs | 10 +++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/cli/args.rs b/src/cli/args.rs index 1de90be..266432f 100644 --- a/src/cli/args.rs +++ b/src/cli/args.rs @@ -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, + + /// 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")] diff --git a/src/commands/mod.rs b/src/commands/mod.rs index a4a3c82..fdf14b3 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -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 {