Pass arguments to ref tasks #308
-
Starting to use poe, which is way nicer than my homebrew scripts, thanks for that! One thing I am trying to do is to pass parameters (not the value!) in a sequence [tool.poe.tasks.all]
sequence = ["format ${check}", "something_without_args"]
args = [{name = "check", type="boolean"}]
[tool.poe.tasks.format]
cmd = 'ruff format ${check:+ --diff}'
args=[{name = "check", type="boolean", help= "Does not correct files, only warns"}]
[tool.poe.tasks.something_without_args]
expr = "not relevant" Now:
The thing is that Is there a way to pass arguments as-is, not there value? i have seen that it is possible to pass values as environment variables, but that is not the behaviour I am looking for, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @guillaume-alliander, Good question! Sadly I'm not sure there's a nice way to do exactly what you're asking for. I guess one nice solution would be if ref tasks also accepted the advanced syntax for parameter expansion Another approach would be to implement another missing feature I've been considering for a while (but I'm not yet convinced about a design) which is to allow all unparsed arguments to be accessed via a single variable like "format ${ALL_ARGS_GO_HERE}". Fantasies aside, a not very satisfying workaround could be to use an switch task like the following example which executes a different sequence depending on whether the [tool.poe.tasks.all]
control.expr = "check"
args = [{name = "check", type="boolean"}]
[[tool.poe.tasks.all.switch]]
case = "True"
sequence = ["format --diff", "something_without_args"]
[[tool.poe.tasks.all.switch]]
sequence = ["format", "something_without_args"]
[tool.poe.tasks.format]
cmd = 'ruff format ${check:+ --diff}'
args=[{name = "check", type="boolean", help= "Does not correct files, only warns"}]
[tool.poe.tasks.something_without_args]
expr = "not relevant" |
Beta Was this translation helpful? Give feedback.
Hi @guillaume-alliander, Good question!
Sadly I'm not sure there's a nice way to do exactly what you're asking for.
I guess one nice solution would be if ref tasks also accepted the advanced syntax for parameter expansion
${check:+ --diff}
. I've been planning to make this syntax acceptable in more places so I'll add this to my list.Another approach would be to implement another missing feature I've been considering for a while (but I'm not yet convinced about a design) which is to allow all unparsed arguments to be accessed via a single variable like "format ${ALL_ARGS_GO_HERE}".
Fantasies aside, a not very satisfying workaround could be to use an switch task like the following example w…