All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scala.cli.commands.util.CommandHelpers.scala Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package scala.cli.commands.util

import scala.build.Logger
import scala.build.errors.BuildException

trait CommandHelpers {

  implicit class EitherBuildExceptionOps[E <: BuildException, T](private val either: Either[E, T]) {
    def orReport(logger: Logger): Option[T] =
      either match {
        case Left(ex) =>
          logger.log(ex)
          None
        case Right(t) => Some(t)
      }
    def orExit(logger: Logger): T =
      either match {
        case Left(ex) => logger.exit(ex)
        case Right(t) => t
      }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy