You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by zephraph January 26, 2025 2025.1.15 macos-arm64 (2025-01-26)
Okay, so I have a mise task that builds a rust crate. I want a windows option (to tell it to build for windows). When it has that option, I want to run cargo xwin build instead of cargo build. (Note I'm doing cross compilation so run_windows won't work for this case).
Here's the monstrosity I have right now
[!NOTE]
This doesn't actually work, I was misreading the output.
[tasks."build:rust"]
run = """{% set windows = flag(name='windows', default='') %}{% if windows == 'true' %} {% set xwin = 'xwin ' %}{% else %} {% set xwin = '' %}{% endif %}echo {{ xwin }}cargo {{ xwin }}build --bin webview -F {{option(name='features', var=true, default='transparent devtools')}}"""
There's a lot of problems to discuss:
I'm not using general sh logic as the docs recommend because the logs only show the first line of output. So if I added an echo 'hello' to the above script the logs would look like this
[build:rust] $ echo hello
I really just want to see the command output (the last line in this case). That's a bit of a separate issue, but still one to note.
It would seem like `{{ flag(name='windows', default='') | replace(from='true', to='xwin') }} should work if it's returning a string. Doesn't seem to be though.
cargo {% if flag(name='windows') %}xwin{% endif %} build seems like it should work, but that throws an exception b/c flag doesn't return a boolean
cargo {% if flag(name='windows') == 'true' %}xwin{% endif %} build doesn't work either
What I'd like to see
One solution that would be nice is just adding an arg to flag that would be the value if it's true. E.g.
{{ flag(name='windows', value='xwin') }}
Another would be to have flag just return a string. I've looked through the code and it looks like it's return some sort of template string that's more of a key? It's weird, because I can't usually get it to print out (it usually just prints as true or nothing).
e.g.
echo '{{ flag(name='windows') }}'
with --window passed will echo true
without it it will echo nothing (e.g. just run echo '')
Funnily, you can see the template string weirdness when you pass it through the reverse filter
echo '{{ flag(name='windows') | reverse }}'
will print GRA_KSAT_ESIM:swodniw:GRA_KSAT_ESIM. This special type doesn't play well with anything else. If we could at least have something we could do to normalize it into a string we'd have some more options.
Thoughts? Recommendations?
The text was updated successfully, but these errors were encountered:
I think my solution to having special strings for flags is not good enough. I think a real solution where the template output is the flag value is what needs to happen in order for templates to work the way users expect.
Discussed in #4237
Originally posted by zephraph January 26, 2025
2025.1.15 macos-arm64 (2025-01-26)
Okay, so I have a mise task that builds a rust crate. I want a windows option (to tell it to build for windows). When it has that option, I want to run
cargo xwin build
instead ofcargo build
. (Note I'm doing cross compilation sorun_windows
won't work for this case).Here's the monstrosity I have right nowThere's a lot of problems to discuss:
sh
logic as the docs recommend because the logs only show the first line of output. So if I added anecho 'hello'
to the above script the logs would look like thisI really just want to see the command output (the last line in this case). That's a bit of a separate issue, but still one to note.
cargo {% if flag(name='windows') %}xwin{% endif %} build
seems like it should work, but that throws an exception b/cflag
doesn't return a booleancargo {% if flag(name='windows') == 'true' %}xwin{% endif %} build
doesn't work eitherWhat I'd like to see
One solution that would be nice is just adding an arg to
flag
that would be the value if it's true. E.g.Another would be to have
flag
just return a string. I've looked through the code and it looks like it's return some sort of template string that's more of a key? It's weird, because I can't usually get it to print out (it usually just prints as true or nothing).e.g.
with
--window
passed will echotrue
without it it will echo nothing (e.g. just run
echo ''
)Funnily, you can see the template string weirdness when you pass it through the reverse filter
will print
GRA_KSAT_ESIM:swodniw:GRA_KSAT_ESIM
. This special type doesn't play well with anything else. If we could at least have something we could do to normalize it into a string we'd have some more options.Thoughts? Recommendations?
The text was updated successfully, but these errors were encountered: