微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决Ammonite:脚本...不接受参数在 OS X 下

使用 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)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。