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

scalafix.internal.config.OutputFormat.scala Maven / Gradle / Ivy

package scalafix.internal.config

import metaconfig.{Conf, ConfDecoder, Configured}

import scalafix.internal.config.MetaconfigPendingUpstream._

sealed abstract class OutputFormat
object OutputFormat {
  def apply(arg: String): Either[String, OutputFormat] = {
    arg match {
      case OutputFormat(format) =>
        Right(format)
      case els =>
        Left(s"Expected one of ${all.mkString(", ")}, obtained $els")
    }
  }
  def all: Seq[OutputFormat] = List(Default, Sbt)
  def unapply(arg: String): Option[OutputFormat] =
    all.find(_.toString.equalsIgnoreCase(arg))
  case object Default extends OutputFormat
  case object Sbt extends OutputFormat
  implicit val decoder: ConfDecoder[OutputFormat] =
    ConfDecoder.instance[OutputFormat] {
      case Conf.Str(str) => Configured.fromEither(OutputFormat(str))
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy