Just SysProcess
libraryDependencies += "io.kevinlee" %% "just-sysprocess" % "1.0.0"
Run on Scastie: https://scastie.scala-lang.org/Kevin-Lee/1Gvwl8I3S4epu5NnoMSjdw
import just.sysprocess._
val sysProcess = SysProcess.singleSysProcess(None, "ls")
val result: Either[ProcessError, ProcessResult] = sysProcess.run()
result match {
case Right(ProcessResult(result)) =>
println(result.mkString("Files: \n -", "\n -", "\n"))
case Left(ProcessError.Failure(code, error)) =>
println(s"[ERROR] Failed: code: $code, ${error.mkString("\n")}")
case Left(ProcessError.FailureWithNonFatal(nonFatalThrowable)) =>
println(s"[ERROR] ${nonFatalThrowable.getMessage}")
}
Run on Scastie: https://scastie.scala-lang.org/Kevin-Lee/j6jWfzr7QtqmUAyPr4TY5w
import just.sysprocess.*
@main def runApp: Unit = {
val sysProcess = SysProcess.singleSysProcess(None, "ls")
val result: Either[ProcessError, ProcessResult] = sysProcess.run()
result match {
case Right(ProcessResult(result)) =>
println(result.mkString("Files: \n -", "\n -", "\n"))
case Left(ProcessError.Failure(code, error)) =>
println(s"[ERROR] Failed: code: $code, ${error.mkString("\n")}")
case Left(ProcessError.FailureWithNonFatal(nonFatalThrowable)) =>
println(s"[ERROR] ${nonFatalThrowable.getMessage}")
}
}