我有以下 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”这样的参数时,我收到以下错误:
[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
这有效:
import complete.DefaultParsers._
val slick = inputKey[Seq[File]]("gen-tables")
slick := {
...
val arg: String = spaceDelimited("<arg>").parsed(0)
...
}
通话内容:
sbt“巧妙的舞台”
sbt“流畅的制作”