Reputation: 3782
I have the following data:
val param1 = List(("f1","f2","f3"),
("d1","d2","d2"))
The number of rows in this List
is not fixed.
I want to pass these data as the input parameter of my Scala object.
import scopt.OptionParser
object Test {
case class Params( param1: List[(String, String, String)] = null )
def main(args: Array[String]) {
val defaultParams = Params()
val parser = new OptionParser[Params]("Test") {
head("bla-bla")
opt[List[(String, String, String)]]("param1")
.required()
.text("xxx")
.action((x, c) => c.copy(param1 = x))
}
parser.parse(args, defaultParams).map { params =>
val processor = new TestProcessor()
processor.run(params)
} getOrElse {
System.exit(1)
}
}
}
How can I do it? Currently, I define String
, but it's not correct. If I use List(String,String,String)
, then it says Type List takes type parameters
.
Upvotes: 0
Views: 3211