Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support array spread in exec #354

Closed
dovahcrow opened this issue Aug 18, 2023 · 7 comments
Closed

Support array spread in exec #354

dovahcrow opened this issue Aug 18, 2023 · 7 comments
Assignees

Comments

@dovahcrow
Copy link

Feature Description

This is similar to #133 but came from cargo-make and is for array:
When using cargo-make, additional parameters are stored in ${@}, like other runners.
However, in duckscript, ${@} is an array, making it impossible to pass to exec.

Describe The Solution You'd Like

Maybe add a new syntax to spread the array?

Code Sample

/// paste code here
exec cargo run --release -- ${@}

Or any new syntax makes the above work.

@sagiegurari
Copy link
Owner

why not do array_join and than spread?

@dovahcrow
Copy link
Author

dovahcrow commented Aug 19, 2023

Yeah array_join then spread is an option I haven't thought of (still thinking in strong typing lol)

Anyway, you can close the issue if you feel a new syntax is unnecessary.

EDIT: does not work for empty args unless you add the special case handling in duckscript as well.

@sagiegurari
Copy link
Owner

just saw the edit, can you tell me what you tried and what you saw?

@dovahcrow
Copy link
Author

dovahcrow commented Sep 2, 2023

@sagiegurari I tried:

[tasks.release]
script = """
files = array_join ${@} " "
exec --fail-on-error tar -cf release.tar must_have.sh %{files}
"""
script_runner = "@duckscript"

cargo make release abc worked, but cargo make release won't.

I can add if to the script but that requires every such usage to add an if.

@sagiegurari
Copy link
Owner

thanks i will check it out

@sagiegurari
Copy link
Owner

@dovahcrow this is now fixed for spread binding and being released.
i'll package and relase a new cargo-make version contain this fix as well soon

@dovahcrow
Copy link
Author

This is great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants