aaronriekenberg / rust-parallel

Fast command line app in rust/tokio to run commands in parallel. Similar interface to GNU parallel or xargs plus useful features. Listed in Awesome Rust utilities.
MIT License
163 stars 7 forks source link

[feature] Please add :::+ capability #19

Open Ktoks opened 6 months ago

Ktoks commented 6 months ago

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.

aaronriekenberg commented 6 months ago

Will work on adding this, thanks for reporting @Ktoks

Ktoks commented 6 months ago

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()