Skip to content
Permalink
Browse files

Introduce editions

If no edition has been configured, default to the latest edition
  • Loading branch information
tdidriksen committed Oct 25, 2019
1 parent 71895e1 commit da30fbf01cdf744f2387b71227fbadec569d89b2
@@ -0,0 +1,20 @@
package org.scalafmt.config

import metaconfig.{Conf, ConfDecoder, ConfEncoder, Configured}

sealed abstract class Edition(val order: Int, val name: String)

object Edition {
implicit val ordering: Ordering[Edition] = Ordering.by[Edition, Int](_.order)

implicit val decoder: ConfDecoder[Edition] = ConfDecoder.instance {
case Conf.Str("2019-10") => Configured.ok(Edition201910)
case _ => Configured.ok(EditionLatest)
}

implicit val encoder: ConfEncoder[Edition] =
ConfEncoder.instance(edition => Conf.Str(edition.name))
}

case object Edition201910 extends Edition(0, "2019-10")
case object EditionLatest extends Edition(Int.MaxValue, "latest")
@@ -159,7 +159,8 @@ case class ScalafmtConfig(
verticalAlignMultilineOperators: Boolean = false,
onTestFailure: String = "",
encoding: Codec = "UTF-8",
project: ProjectFiles = ProjectFiles()
project: ProjectFiles = ProjectFiles(),
edition: Edition = EditionLatest
) {
private implicit val runnerReader = runner.reader
private implicit val projectReader = project.reader

0 comments on commit da30fbf

Please sign in to comment.
You can’t perform that action at this time.