How to make sbt task call project code with console arguments

I don't know how to make "sbt invoke project code" and "using console arguments" together. However, I know that I can do this separately.

Set up an sbt task to invoke the project code . Basically, this can be found in sbt task definition that calls a method from project code?

Sample code:

val generateJson = inputKey[Unit]("generate json ...")

fullRunInputTask(generateJson, Test, "json.JsonGenerator")

      

Also, this is the document for the task input argument . http://www.scala-sbt.org/0.13/docs/Input-Tasks.html

generateJson := {
  // get the result of parsing
  val args: Seq[String] = spaceDelimited("<arg>").parsed
  // Here, we also use the value of the `scalaVersion` setting
  println("The current Scala version is " + scalaVersion.value)
  println("The arguments to demo were:")
  args foreach println
}

      

May I know how to combine these 2 things?

Thank you very much in advance

+3


source to share





All Articles