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-access syntax #402

Closed
cdmistman opened this issue Mar 29, 2020 · 5 comments
Closed

Support array-access syntax #402

cdmistman opened this issue Mar 29, 2020 · 5 comments
Assignees
Milestone

Comments

@cdmistman
Copy link

Features Description
There should be some kind of syntax for accessing arrays. For example, this would be useful following @@split(string,delimiter).

Describe the solution you'd like
A simple square-bracket based array-access syntax following cargo make functions.

Code Sample

[env]
# This could be the name of a rustc-supported triplet or a custom-defined triplet
TARGET = { value = "default.json", condition = { env_not_set = "THING" } }

[tasks.print]
command = "echo"
args = ["now starting build for", "@@split(TARGET,.)[0]"]

[tasks.build]
dependencies = ["print"]
command = "cargo"
# TARGET here is used regardless of whether or not it is a file
args = ["build", "--target", "${THING}"]
@sagiegurari
Copy link
Owner

nice. i can create a new function that splits and gets like
getat(envvar,delimiter,index)
if its out of bounds the entire arg is removed (like split does if the env var is empty or doesn't exist)

@sagiegurari sagiegurari added this to the 0.30.2 milestone Mar 29, 2020
@sagiegurari
Copy link
Owner

by the way, you can do something already today.
you could have some task that is invoking duckscript script that splits and takes the argument.
then it can set it as a new env var to be accessed by other tasks.

I will implement the new function, but just wanted to point out that you are not completely blocked at the moment.

sagiegurari added a commit that referenced this issue Mar 29, 2020
@sagiegurari
Copy link
Owner

@cdmistman you can try the 'getat' function now available in the dev branch 0.30.2
it works like the split, but accepts a third param which is the index to return.

you can look at docs + example:

https://github.com/sagiegurari/cargo-make/tree/0.30.2#usage-functions-getat

@cdmistman
Copy link
Author

thanks!

@sagiegurari
Copy link
Owner

this is now released in 0.30.2 cargo-make version.
thanks for the feedback.

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

No branches or pull requests

2 participants