Closed coderaiser closed 1 week ago
Hi @coderaiser. This is possible. A week ago there was a new feature introduced in main
block that will give you all arguments passed to Amber. This is not documented yet although it has to be asap.
Here is the code example that demonstrates how to do it:
main (args) {
let arg = args[1]
echo "Username: {arg}"
}
Thank you, I fugured out another work around:
main {
let file = "$1"
let size = "$2"
}
This is also good, but it counts from zero, as I see:
main(args) {
let file = args[0];
let size = args[1];
}
Just rewritten one of my bash utilities to Amber, could you please point me up if I could use more ergonomic constructions?
https://github.com/coderaiser/loop/blob/master/src/loop.ab
Also I think would be great to support export
instead of pub
, since we have import
. For other parts of language - it looks really good, the things that is missing is: linter (with autofixes) and formatter.
Thanks for a great work!
That's a good point! import
and export
is more idiomatic. We can change that since we're still in an unstable alpha. Sorry for that mistake - it should be args[1]
indeed. Linting and formatting is on the list. Probably when we integrate LSP.
@coderaiser your project is looking good. I hope once Amber evolves it will be even easier to write shell scripts. The RDC (realtime dependency checking) is on the way so you'll probably don't need to check for each command to exist. You could remove that code in the future as Amber will do it by itself
Could you please tell me how to write this in Amber:
I need to take command line arguments for script I'm working on. Can't find this in documentation. Is it possible?