Using ammonite, I am trying to run a script that takes command line arguments. I just can't figure out what I am doing wrong. It works under Linux with a different version of ammonite, but not under OS X using homebrew:
According to the documentation this is how to do it:
val x = 1
@main
def main(i: Int, s: String, path: os.Path = os.pwd) = {
println("hello");
s"Hello! ${s * i} ${path.last}."
}
println("hello 2");
however, the @main annotation does not seem to do anything:
[dmg:/tmp] % amm rip7.sc --i=3 --s='this is the'
hello 2
Script rip7.sc does not take arguments: "--i=3" "--s=this is the"
⌁ [dmg:/tmp] 1 % amm rip7.sc 3 'this is the'
hello 2
Script rip7.sc does not take arguments: "3" "this is the"
The version of amm is (running on mac, using homebrew):
[dmg:/tmp] % amm
Loading...
Welcome to the Ammonite Repl 2.4.0 (Scala 3.0.0 Java 16.0.1)
@
This same program runs on linux:
% amm /tmp/rip7.sc --i 10 --s 'the end'
Compiling /tmp/rip7.sc
hello 2
hello
"Hello! the endthe endthe endthe endthe endthe endthe endthe endthe endthe end dmg."
ammonite version:
% amm
Loading...
Compiling (synthetic)/ammonite/predef/sourceBridge.sc
Compiling (synthetic)/ammonite/predef/frontEndBridge.sc
Welcome to the Ammonite Repl 2.0.4 (Scala 2.13.1 Java 11.0.11)