-
Hi, is it possible to have dependencies between arguments and conditionally set value of one argument based on value of different argument ? Example in basic form
What I would like to happen: => when deploying to
Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @pklejch, I would usually solve this with a switch task though this is a bit verbose. The problem of how to conditionally include part of a cmd task based on args is something I have encountered but haven't come up with a satisfactory solution for yet (ideas welcome). Another workaround would be to put the conditional logic in another task and depend on it like so: [tool.poe.tasks.deploy]
cmd = "./deploy $env $options"
args = ["env"]
uses = {"options" = "_deploy_options ${env}"}
[tool.poe.tasks._deploy_options]
expr = "${param} == 'dev' and '--argA=123' or ''"
args = [{ name = "param", positional = true, required = false}] Here I use a expr for the helper task but you could use cmd too. It's not the cleanest solution but it might work for you. Sometimes the simplest solution is just to use a shell task with bash flow control, although I usually try to avoid this approach because it's less portable and I don't like the aesthetic of having procedural "code" inside declarative config. |
Beta Was this translation helpful? Give feedback.
Hi @pklejch,
I would usually solve this with a switch task though this is a bit verbose. The problem of how to conditionally include part of a cmd task based on args is something I have encountered but haven't come up with a satisfactory solution for yet (ideas welcome).
Another workaround would be to put the conditional logic in another task and depend on it like so:
Here I use a expr for the helper task but you could use cmd t…