I'm trying to capture the stdout and stderr streams from an external process that requires user input. So far I've focused my efforts on using the tools available in the scala.sys.process
package. I can get the user interaction or the stream capturing working correctly, but not both at the same time. I've added a straightforward test case that has examples of both behaviors. I suspect I'm not connecting the in/out streams correctly but I'm a little lost.
import scala.sys.process._
object Test extends App {
val processLogger = ProcessLogger(
(out: String) => println(s"OUT: $out"),
(err: String) => println(s"ERR: $err")
)
val cmd = "sbt new scala/scala-seed.g8"
// Allows user interaction but doesn't allow capture of stdout/stderr
val exitCode1 = cmd.run(connectInput = true).exitValue()
// Allows stdout/stderr capture but user input prompt is not displayed
val exitCode2 = cmd.run(processLogger, connectInput = true).exitValue()
}