Skip to content

Add CLI support for command templates/matrix commands #517

Open
@cdrini

Description

@cdrini

It would be useful to be able to generate the commands dynamically based on an environment variable. For example:

concurrently --matrix "A B C" "echo {}"

Which would be equivalent to typing:

concurrently "echo A" "echo B" "echo C"

Or with multiple values you could do:

concurrently --matrix "A B C" --matrix "1 2 3" "echo {1}{2}"

Which would be equivalent to writing:

concurrently "echo A1" "echo "A2" "echo A3" "echo B1" "echo B2" "echo B3" "echo C1" "echo C2" "echo C3"

This would be useful for common repetitive tasks that can happen in parallel. For example, let's say I want to download some docker image on a few different servers. I could do:

SERVERS="server1 server2"
IMAGES="python:3.11 node:20"

concurrently --group --matrix "$SERVERS" --matrix "$IMAGES" "ssh {1} 'docker pull {2}'"

This would help making concurrently a drop-in replacement for bash for-loops; the above would replace

for server in $SERVERS; do
    for image in $IMAGES; do
        ssh $server "docker pull $image"
    done
done

It would also make concurrently a drop-in for a lot of gnu parallel usages, eg:

parallel --quote ssh {1} "docker pull {2}" ::: $SERVERS ::: $IMAGES

Another example: processing a lot files in parallel, eg less compiling a number of files:

concurrently --matrix "$(ls *.less)" --group "lessc {}"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions