Repository navigation
Conditionally passing boolean flags to task dependencies #11044
michael-skovik
started this conversation in
Ideas
Replies: 1 comment 1 reply
|
Thanks for the detailed report. I confirmed this was an asymmetry between dependency forms: structured I opened #11055 to omit structured arguments that contain template syntax and render empty. The proposed fix preserves literal empty arguments such as With that change, the original structured form works as expected: depends = [{ task = "lint:*", args = ["{% if usage.fix %}--fix{% endif %}"] }]This comment was generated by an AI coding assistant. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, I saw that passing arguments to task dependencies was added not too long ago (#8893). A great addition!
However, reading the docs (https://mise.jdx.dev/tasks/task-configuration.html#passing-parent-task-arguments-to-dependencies), I could not find a 'native' way to pass boolean flags that do not take arguments since they simply populate the
usagemap as{ "flag_name" => true }.For example, if I have a high level task
lintthat accepts a--fix, it can't be passed conditionally through theargs =field ofdepends:I tried doing something like this:
But it errors out with:
Since without the flag it evaluates to
args = [""]which errors out compared toargs = [].Adding an argument to
--fixworks:But that kind of defeats the point of boolean flags, since we can no longer do
mise r lint --fix(it will default tofalse).The only solution I found so far is to bypass the whole
{ task = ..., args = ... }syntax and use argument passing directly independslike so:To be honest, I am not sure what the best syntax for passing these flags in
argswould be.Maybe it should be possible to do
args = ["{% if usage.fix %}--fix{% endif %}"]?Or a new field in the
dependsmap objects, e.g{ task = ..., args = ..., boolean_flags = ["--fix", "--foo", ...] }?All reactions