Handle leftover arguments with Leftover[T]
mainUse the Leftover[T] type to capture any tokens that are not consumed by other defined parameters. This is useful for implementing commands that take a variable number of arguments at the end of the command line.
You can specify the type for Leftover, such as Leftover[String] or Leftover[Int]. If tokens do not conform to the specified type, a parsing error will occur.
package testvararg
import mainargs.{main, arg, Parser, Leftover}
object Main{
@main
def run(foo: String,
myNum: Int = 2,
rest: Leftover[String]) = {
println(foo * myNum + " " + rest.value)
}
def main(args: Array[String]): Unit = Parser(this).runOrExit(args)
}