我有一个 Windows 批处理
@echo off
setlocal
call kotlinc-jvm -cp "%~dp0\lib\commons-cli-1.3.1.jar" -script "%~dp0\RmMvnRepo.kts" %*
endlocal
Run Code Online (Sandbox Code Playgroud)
如果我将“-h”选项传递给批处理,则会显示 kotlinc-jvm 自己的帮助。但我希望我RmMvnRepo.kts能收到这个选项。怎么做?
编辑:不需要再回答这个问题了。我在 kotlinc 中发现了与此相关的错误。
想象一下包含在 main 函数中的代码。然后您可以通过数组访问参数args。
Call the script with arguments
kotlinc -script ...kts "option1" "option2"
Run Code Online (Sandbox Code Playgroud)
Access the arguments through args variable
println(args.size) // will output 2
Run Code Online (Sandbox Code Playgroud)
更新:尝试用引号传递 -h 参数
kotlinc -script ...kts "%*"
Run Code Online (Sandbox Code Playgroud)
正如 @mfulton 所建议的,这个问题描述了问题,所以我将关闭这个问题。
来自对该票的评论:
这在 1.1.3 中可以使用“--”分隔符作为编译器参数和其余参数(自由参数):
以及评论的示例用法--:
Run Code Online (Sandbox Code Playgroud)kotlinc -script foo.kts -- -arg value
| 归档时间: |
|
| 查看次数: |
5779 次 |
| 最近记录: |