diff --git a/src/cli/args.rs b/src/cli/args.rs index 05b522c6..42b9d1b7 100644 --- a/src/cli/args.rs +++ b/src/cli/args.rs @@ -45,6 +45,10 @@ pub struct CliArgs { #[arg(short = 'p', long = "password", global = true)] pub password: Option, + /// cocurrent working threads + #[arg(short = 't', long, global = true)] + pub threads: Option, + // Ouch and claps subcommands #[command(subcommand)] pub cmd: Subcommand, @@ -138,6 +142,7 @@ mod tests { format: None, // This is usually replaced in assertion tests password: None, + threads: None, cmd: Subcommand::Decompress { // Put a crazy value here so no test can assert it unintentionally files: vec!["\x00\x11\x22".into()], diff --git a/src/cli/mod.rs b/src/cli/mod.rs index ce6b5d59..4144e53e 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -28,6 +28,13 @@ impl CliArgs { set_accessible(args.accessible); + if let Some(threads) = args.threads { + rayon::ThreadPoolBuilder::new() + .num_threads(threads) + .build_global() + .unwrap(); + } + let (Subcommand::Compress { files, .. } | Subcommand::Decompress { files, .. } | Subcommand::List { archives: files, .. }) = &mut args.cmd;