我有以下sbt任务,我想将参数传递给:
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))
}
然而,当我运行它并传递像'sbt slick prodEnv'这样的arg时,我收到以下错误:
[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
[error]
答案 0 :(得分:1)
这有效:
import complete.DefaultParsers._
val slick = inputKey[Seq[File]]("gen-tables")
slick := {
...
val arg: String = spaceDelimited("<arg>").parsed(0)
...
}
致电:
sbt&#39; slick staging&#39;
sbt&#39; slick production&#39;