Ammonite:脚本...不接受参数(在 OS X 下)

时间:2021-06-28 21:03:01

标签: macos scala ammonite

使用 ammonite,我试图运行一个接受命令行参数的脚本。我只是无法弄清楚我做错了什么。它可以在使用不同版本 ammonite 的 Linux 下运行,但不能在使用自制软件的 OS X 下运行:

根据文档,这是如何做到的:

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"); 

然而,@main 注释似乎没有做任何事情:

[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"

amm 的版本是(在 mac 上运行,使用 homebrew):

[dmg:/tmp] % amm       
Loading...
Welcome to the Ammonite Repl 2.4.0 (Scala 3.0.0 Java 16.0.1)
@  

同样的程序在 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."

菊石版:

% 毫米

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)

0 个答案:

没有答案
相关问题