Read from stdin to sbt task

Suppose I have the following code

object Cli extends App { Iterator.continually(StdIn.readLine()).takeWhile(!_.equals("quit")).foreach { command => println(s"[$command RESULT] " + ApiClient.executeCommand(command)) } } 

and sbt user command

 val cli = inputKey[Unit]("Run client") cli := { "java -cp my.jar Cli".! } 

If I run "java -cp my.jar Cli" from the console, it works fine. But when I call "sbt cli", it fails with a NullPointerException

 Exception in thread "main" java.lang.NullPointerException at Cli$$anonfun$2.apply(Cli.scala:14) 

How to define sbt task to read commands from stdin?

+4
source share
1 answer

Add this to build.sbt

 fork := true 

See http://www.scala-sbt.org/1.x/docs/Forking.html

0
source

All Articles