Skip to content

Conversation

cdrini
Copy link
Contributor

@cdrini cdrini commented Jan 16, 2025

Closes #517

Sample runs:

Single dimension:

$ dist/bin/concurrently.js --group --matrix "os:windows linux" 'echo {M:os}'
[0] windows
[0] echo windows exited with code 0
[1] linux
[1] echo linux exited with code 0

Multiple dimensions:

$ dist/bin/concurrently.js --group -M "os:windows linux" -M "version:10 12 14" 'echo {M:os} (version {M:version})'
[0] windows (version 10)
[0] echo windows (version 10) exited with code 0
[1] windows (version 12)
[1] echo windows (version 12) exited with code 0
[2] windows (version 14)
[2] echo windows (version 14) exited with code 0
[3] linux (version 10)
[3] echo linux (version 10) exited with code 0
[4] linux (version 12)
[4] echo linux (version 12) exited with code 0
[5] linux (version 14)
[5] echo linux (version 14) exited with code 0

With environment variables:

$ SERVERS="$(echo ol-web{0..2})"
$ IMAGES="python:3.12-slim python:3.13-slim"
$ dist/bin/concurrently.js --group -r -M "server:$SERVERS" -M "image:$IMAGES" 'echo ssh {M:server} docker image pull {M:image}'
ssh ol-web0 docker image pull python\:3.12-slim
ssh ol-web0 docker image pull python\:3.13-slim
ssh ol-web1 docker image pull python\:3.12-slim
ssh ol-web1 docker image pull python\:3.13-slim
ssh ol-web2 docker image pull python\:3.12-slim
ssh ol-web2 docker image pull python\:3.13-slim
ssh ol-web1 docker image pull python\:3.12-slim
ssh ol-web1 docker image pull python\:3.13-slim
ssh ol-web2 docker image pull python\:3.12-slim
ssh ol-web2 docker image pull python\:3.13-slim
ssh ol-web2 docker image pull python\:3.12-slim
ssh ol-web2 docker image pull python\:3.13-slim

@cdrini cdrini force-pushed the 517/feature/matrix-option branch from ecdae50 to 5af7c99 Compare January 16, 2025 01:56
@coveralls
Copy link

coveralls commented Jan 16, 2025

Coverage Status

coverage: 99.841%. first build
when pulling cbed67a on cdrini:517/feature/matrix-option
into 7631bec on open-cli-tools:main.

@cdrini cdrini force-pushed the 517/feature/matrix-option branch from 5af7c99 to dfc3c5f Compare January 16, 2025 01:57
@cdrini cdrini force-pushed the 517/feature/matrix-option branch from dfc3c5f to f656f5d Compare January 16, 2025 02:16
@cdrini cdrini marked this pull request as ready for review January 16, 2025 02:38
@gustavohenke gustavohenke self-requested a review January 27, 2025 21:53
Copy link
Member

@gustavohenke gustavohenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this up!
I made several suggestions and asked a few questions in this pass.

I'll update the docs to mention matrices as well in a follow-up, unless you feel like doing it while keeping it on brand?

@paescuj paescuj marked this pull request as draft August 28, 2025 13:45
@paescuj
Copy link
Collaborator

paescuj commented Aug 30, 2025

@cdrini Wanna take this up again?

@cdrini
Copy link
Contributor Author

cdrini commented Sep 7, 2025

Thank you for rebasing, @paescuj ! And thank you for the code review @gustavohenke . Apologies for the delay was a bit stuck on the right approach. Taking another look today.

- also require M: prefix in placeholder
- avoids conflicting with pass-through args
- avoids having two ways of specifying the matrix with or without ':'
- makes the command easier to read
I confused the term, we're creating a single matrix, as defined by
multiple dimensions/axes.
@cdrini
Copy link
Contributor Author

cdrini commented Sep 8, 2025

Ok! I updated this up with the comments. I decided to tweak the interface slightly to allow/enforce named matrix dimensions, and a M: prefix for the matrix placeholder in the command (eg --matrix "os:windows linux" 'echo {M:os}'). This not only fixes the collisions issue with the placeholder for pass-through arguments, but also avoids an issue I've noticed with GNU parallel, which is that it very quickly becomes unreadable with very many eg {1} {3} {2}. It also avoids having to have extra options for names (something GNU parallel supports IIRC), which I think fragments the interface a bit. Now there's one interface that kind of handles it all. Although at the cost of being a bit more verbose.

I updated the description with the new interface. Would love to know your thoughts!

Note: I also fixed a naming error I'd made in the code; there aren't multiple matrices, there is just one matrix!

Also if anyone has any thoughts on why that mac test is failing... 🤔 Thank you to whoever I assume re-ran it.

@cdrini cdrini marked this pull request as ready for review September 8, 2025 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CLI support for command templates/matrix commands
4 participants