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

[Feature Request] cast command output to array #71

Closed
kilianc opened this issue May 22, 2024 · 4 comments · Fixed by #73
Closed

[Feature Request] cast command output to array #71

kilianc opened this issue May 22, 2024 · 4 comments · Fixed by #73
Assignees

Comments

@kilianc
Copy link
Contributor

kilianc commented May 22, 2024

main {
  let files = $ls ../$? as [Text]

  loop index, file in files {
    echo "{index}: {file}"
  }
}
@Ph0enixKM
Copy link
Member

As of right now (Amber alpha 0.31) this unfortunately does not cast properly due to the way Bash handles arrays. I'll write a simple standard library function that does just what you want to accomplish. Stay tuned

@Ph0enixKM Ph0enixKM self-assigned this May 22, 2024
@Ph0enixKM Ph0enixKM linked a pull request May 22, 2024 that will close this issue
@Ph0enixKM
Copy link
Member

Added, @kilianc 🙏. In order to use this function you have to uninstall and install amber again. Here is the usage:

import { lines } from "std"

main {
  let files = $ls ../$?

  loop index, file in lines(files) {
    echo "{index}: {file}"
  }
}

@kilianc
Copy link
Contributor Author

kilianc commented May 22, 2024

I simply downloaded the binary because I don't like to run scripts on my machine, would a redownload do it?

@Ph0enixKM
Copy link
Member

@kilianc I just reuploaded the binaries. You can now reinstall amber the manual way

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

Successfully merging a pull request may close this issue.

2 participants