mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-03 10:00:19 +00:00
feat: add concurrent working threads option to CLI args
This commit is contained in:
parent
195483a182
commit
6b38e1dd46
@ -45,6 +45,10 @@ pub struct CliArgs {
|
||||
#[arg(short = 'p', long = "password", global = true)]
|
||||
pub password: Option<OsString>,
|
||||
|
||||
/// cocurrent working threads
|
||||
#[arg(short = 't', long, global = true)]
|
||||
pub threads: Option<usize>,
|
||||
|
||||
// Ouch and claps subcommands
|
||||
#[command(subcommand)]
|
||||
pub cmd: Subcommand,
|
||||
@ -142,6 +146,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()],
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user