Version Matrix

just-sysprocess

Just SysProcess

Build Status Release Status

Latest version Maven Central

libraryDependencies += "io.kevinlee" %% "just-sysprocess" % "1.0.0"

Example

Scala 2.11 ~ 2.13

Run on Scastie: https://scastie.scala-lang.org/qb8MfQbxTCql9ZhTR1POCw

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}")
}

Scala 3 (Dotty)

Run on Scastie: https://scastie.scala-lang.org/fe7qYl9uTkSOX9VpyHZzHw

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}")
  }
}