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
scala sbt


source to share


No one has answered this question yet

See similar questions:

17
Defining an sbt task that calls a method from your project code?

or similar:

34
An idiomatic way of writing multi-draft compilations with .sbt files in sbt 0.13
17
Defining an sbt task that calls a method from your project code?
five
How do I create a task that prints command line arguments?
4
How do you match string surrounded by optional whitespace with SBT Parsers
3
How can I run "sbt hello, world"?
3
SBT InputKey with property arguments
2
Is there a way to deploy the SBT console to a new JVM?
1
How do I define a custom configuration to filter ScalaTest tests in build.sbt file?
1
How does sbt know how to find the application folder for the source codes in the game environment?
0
scala reference sbt project version



All Articles
Loading...
X
Show
Funny
Dev
Pics