mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-05 02:55:31 +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)]
|
#[arg(short = 'p', long = "password", global = true)]
|
||||||
pub password: Option<OsString>,
|
pub password: Option<OsString>,
|
||||||
|
|
||||||
|
/// cocurrent working threads
|
||||||
|
#[arg(short = 't', long, global = true)]
|
||||||
|
pub threads: Option<usize>,
|
||||||
|
|
||||||
// Ouch and claps subcommands
|
// Ouch and claps subcommands
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub cmd: Subcommand,
|
pub cmd: Subcommand,
|
||||||
@ -142,6 +146,7 @@ mod tests {
|
|||||||
format: None,
|
format: None,
|
||||||
// This is usually replaced in assertion tests
|
// This is usually replaced in assertion tests
|
||||||
password: None,
|
password: None,
|
||||||
|
threads: None,
|
||||||
cmd: Subcommand::Decompress {
|
cmd: Subcommand::Decompress {
|
||||||
// Put a crazy value here so no test can assert it unintentionally
|
// Put a crazy value here so no test can assert it unintentionally
|
||||||
files: vec!["\x00\x11\x22".into()],
|
files: vec!["\x00\x11\x22".into()],
|
||||||
|
@ -28,6 +28,13 @@ impl CliArgs {
|
|||||||
|
|
||||||
set_accessible(args.accessible);
|
set_accessible(args.accessible);
|
||||||
|
|
||||||
|
if let Some(threads) = args.threads {
|
||||||
|
rayon::ThreadPoolBuilder::new()
|
||||||
|
.num_threads(threads)
|
||||||
|
.build_global()
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
let (Subcommand::Compress { files, .. }
|
let (Subcommand::Compress { files, .. }
|
||||||
| Subcommand::Decompress { files, .. }
|
| Subcommand::Decompress { files, .. }
|
||||||
| Subcommand::List { archives: files, .. }) = &mut args.cmd;
|
| Subcommand::List { archives: files, .. }) = &mut args.cmd;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user