-
-
Notifications
You must be signed in to change notification settings - Fork 371
Open
Description
Consider MyScript.sc:
@main
def doTheThing(
@arg(short='p') parallelism: Int = 1,
@arg dry: Flag,
@arg ids: Leftover[Int]
) = {
println(s"parallelism: $parallelism")
println(s"dry: ${dry.value}")
println(s"ids: ${ids.value.mkString("[", ", ", "]")}")
}Currently I can invoke this like:
$ amm MyScript.sc 4 5 6 7
parallelism: 4
dry: true
ids: [6, 7]
I think it's clear how the arguments are being misconstrued. What I'd like to have is:
$ amm MyScript.sc 4 5 6 7
parallelism: 1
dry: false
ids: [4, 5, 6, 7]
As far as I can tell, this is because the main method is invoked with allowPositional = true (Scripts.scala:109).
I believe forwarding allowPositional to ammonite.Main should allow this to be configured at least in an embedded environment. Adding a command line argument shouldn't be that much more effort.
If I'm mistaken, this may end up being an improvement for mainargs instead.
I have confirmed that allowPositional = false results in the expected behavior.
Metadata
Metadata
Assignees
Labels
No labels