I am trying to use the new immutable OptionParser
in the Scala scopt 2.0.1 library. Since OptionParser
takes a generic type and the help method already defines an action that returns Unit
, I am getting a compile-time error:
case class Config(directory: String = null)
val parser = new OptionParser[Config]() {
def options = Seq(
opt("d", "directory", "directory containing the files to be processed") {
(value: String, config: Config) => config.copy(directory = value)
},
help("?", "help", "Show a usage message and exit"))
}
error: type mismatch;
[INFO] found : scopt.generic.FlagOptionDefinition[Nothing]
[INFO] required: scopt.generic.OptionDefinition[Config]
[INFO] Note: Nothing <: Config, but class OptionDefinition is invariant in type C.
How can I include a "help" option?