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?
source share