Replies: 3 comments 4 replies
-
flag() doesn't really work the way you'd expect, it's just emitting a special key that gets gsub'ed later on. This has come up a couple of times and it might be fixable but it would require some refactoring and probably require us to parse the run script twice (once to get the args/flags, and another to generate the script). I was trying to avoid parsing twice but it's probably best to do so.
EDIT: sorry I re-read this and see you're actually running this from unix For now I think you'll just need to put this logic into bash, doing something like this: local windows={{ flag(name='windows') }}
if [ "$windows" == true ]; then
# ... that's the way I intended people would use this, but I definitely see why you're expecting templates to work here |
Beta Was this translation helpful? Give feedback.
-
Here's what I'm doing right now: run = """
XWIN=$([ "{{ flag(name='windows') }}" = "true" ] && echo xwin || echo "")
cargo $XWIN build --bin webview -F {{option(name='features', var=true, default='transparent devtools')}}
""" biggest problem is the log output
because it's on two lines it's not showing what command it's actually running which is unfortunate (because I often check that to figure out why builds fail etc) |
Beta Was this translation helpful? Give feedback.
-
What does seem to work is storing it in a variable first before the statement.
|
Beta Was this translation helpful? Give feedback.
-
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 nowNote
This doesn't actually work, I was misreading the output.
There'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?
Beta Was this translation helpful? Give feedback.
All reactions