Pixi task specification should support explicit argument parameterization
Problem description
In the task specification, it would be very nice to be able to parameterize the arguments passed to the task.
Simply provided named positional args that could then be substituted using env-variables would be a great starting point.
For example, something like:
paramterized = { positional_args = [ "ARG1", "ARG2"], cmd = "python src/foo.py $ARG1 | python src/bar.py $ARG2 --some-flag"}
This would allow using arguments in a way that isn't possible with the current append-only version of passing in args. Without this we need to add an extra level of indirection to accomplish these kinds of invocations.
Additionally having structured args like would allow the args to be listed as part of pixi task list, making it more self-documenting how the task is intended to be invoked.
I like the idea, let us think about this some more!
We've had some other users propose support for $1 $2 $... like bash does.
I like this idea too. To add my 2¢, you don't have to write long inline tables to achieve this:
[tasks]
[tasks.paramterized]
positional_args = [ "ARG1", "ARG2"]
cmd = "python src/foo.py $ARG1 | python src/bar.py $ARG2 --some-flag"
Also, I would suggest a syntax for variadic arguments, so that this remains compatible with the current append-only argument passing.
For example, just uses *VARARG for zero or more arguments and +VARARG for one or more. An example recipe/task in just...
commit MESSAGE *FLAGS:
git commit {{FLAGS}} -m "{{MESSAGE}}"
...could serve as inspiration for pixi:
[tasks]
[tasks.commit]
signature = ["MESSAGE", "*FLAGS"] # required and variadic arguments, respectively
cmd = ["git", "commit", "$FLAGS", "-m", "$MESSAGE"]
This is now fixed using the arguments implementation, we've taking great inspiration from just and task. There are still lots of improvements we can do, but I will close this issue for now.
Amazing! Very excited to give this a try.