Skip to content

Dependencies between arguments #242

Answered by nat-n
pklejch asked this question in Q&A
Sep 17, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

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 t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pklejch
Comment options

Answer selected by pklejch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants