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 .

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


source to share

All Articles