From 639ffbe8964f4b822d61a17e23e30f7364c74d33 Mon Sep 17 00:00:00 2001 From: ttyS3 Date: Sat, 30 Nov 2024 17:43:50 +0000 Subject: [PATCH] feat: add concurrent working threads option to CLI args --- src/cli/args.rs | 4 ++++ src/cli/mod.rs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/cli/args.rs b/src/cli/args.rs index 05b522c60..3dddd5334 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, diff --git a/src/cli/mod.rs b/src/cli/mod.rs index ce6b5d591..8d38b4473 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -28,6 +28,11 @@ impl CliArgs { set_accessible(args.accessible); + rayon::ThreadPoolBuilder::new() + .num_threads(args.threads.unwrap_or(0)) + .build_global() + .unwrap(); + let (Subcommand::Compress { files, .. } | Subcommand::Decompress { files, .. } | Subcommand::List { archives: files, .. }) = &mut args.cmd;