rust-parallel icon indicating copy to clipboard operation
rust-parallel copied to clipboard

[feature] Please add :::+ capability

Open Ktoks opened this issue 1 year ago • 2 comments

To allow for commands that run once on each option - please add :::+ capability (similar to gnu-parallel). This would make this tool a drop-in replacement for gnu-parallel for many commands I use. I'm sure others would benefit from the speed improvements over Perl that Rust provides.

Ktoks avatar May 03 '24 22:05 Ktoks

Will work on adding this, thanks for reporting @Ktoks

aaronriekenberg avatar May 05 '24 09:05 aaronriekenberg

I think I've figured out where the largest amount of change would need to take place for this - src/parser/command_line.rs:

@@ -3,7 +3,7 @@ use itertools::Itertools;
 use std::{collections::VecDeque, sync::Arc};

 use crate::{
-    command_line_args::{CommandLineArgs, COMMANDS_FROM_ARGS_SEPARATOR},
+    command_line_args::{CommandLineArgs, COMMANDS_FROM_ARGS_SEPARATOR, COMMANDS_FROM_ARGS_SEPARATOR_SEQUENTIAL},
     common::OwnedCommandAndArgs,
     parser::{regex::RegexProcessor, ShellCommandAndArgs},
 };
@@ -45,6 +45,7 @@ impl CommandLineArgsParser {
         for (separator, group) in &command_and_initial_arguments
             .iter()
             .group_by(|arg| *arg == COMMANDS_FROM_ARGS_SEPARATOR)
+            .group_by(|arg| *arg == COMMANDS_FROM_ARGS_SEPARATOR_SEQUENTIAL)
         {
             let group_vec = group.cloned().collect();

@@ -53,11 +54,15 @@ impl CommandLineArgsParser {
                     first_command_and_args = group_vec;
                 }
                 first = false;
+            // TODO: this will be where we add a new group type
+            // } else if condition {
+            //     unimplemented!();
             } else if !separator {
                 remaining_argument_groups.push(group_vec);
             }
         }

+        // TODO: Figure out how to run this sequential
         let all_argument_groups = remaining_argument_groups
             .into_iter()
             .multi_cartesian_product()

Ktoks avatar May 05 '24 14:05 Ktoks