I have the following sbt task that I'd like to pass an argument to:
import sbt.complete._
import complete.DefaultParsers._
val stageEnv: Parser[String] = " staging"
val prodEnv : Parser[String] = " production"
val combinedParser: Parser[String] = stageEnv | prodEnv
slick := slickCodeGenTask.value
lazy val slick = inputKey[InputTask[Seq[File]]]("gen-tables")
lazy val slickCodeGenTask = Def.inputTask {
...
s.log.info(combinedParser.parsed.trim)
Seq(file(fname))
}
However, when I run it and pass an arg like 'sbt slick prodEnv' I get the following error:
[error] Not a valid command: prodEnv
[error] Not a valid project ID: prodEnv
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: prodEnv (similar: products)
[error] prodEnv
This worked:
import complete.DefaultParsers._
val slick = inputKey[Seq[File]]("gen-tables")
slick := {
...
val arg: String = spaceDelimited("<arg>").parsed(0)
...
}
Then call with:
sbt 'slick staging'
sbt 'slick production'