Skip to content
This repository has been archived by the owner on Sep 17, 2022. It is now read-only.

Update scalafmt-core to 3.5.1 #97

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.5.0
version = 3.5.1

maxColumn = 120
runner.dialect = scala213source3
Expand Down
43 changes: 25 additions & 18 deletions morphir-cli/src/main/scala/zio/morphir/cli/CliCommand.scala
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
package zio.morphir.cli
import zio.cli.{Command, Options}

final case class CliCommand[+CommandDetails](subcommand: CommandDetails, verbosity: Verbosity = Verbosity.Normal)

final case class CliCommand[+CommandDetails](subcommand:CommandDetails, verbosity: Verbosity = Verbosity.Normal)

object CliCommand{
sealed trait Subcommand extends Product with Serializable
object CliCommand {
sealed trait Subcommand extends Product with Serializable
sealed trait ElmSubcommand extends Subcommand
object Subcommand {
final case class Elm(elmSubcommand:ElmSubcommand) extends Subcommand
final case class ElmMake() extends ElmSubcommand
final case class ElmGen() extends ElmSubcommand
final case class Make() extends Subcommand
final case class Elm(elmSubcommand: ElmSubcommand) extends Subcommand
final case class ElmMake() extends ElmSubcommand
final case class ElmGen() extends ElmSubcommand
final case class Make() extends Subcommand
}

lazy val verbosityFlag = Options.enumeration("verbosity")("quiet" -> Verbosity.Quiet, "normal" -> Verbosity.Normal, "verbose" -> Verbosity.Verbose).alias("v").withDefault(Verbosity.Normal)
lazy val elm: Command[CliCommand[Subcommand.Elm]] = Command("elm").subcommands(elmMake, elmGen).map{ cmd => CliCommand(Subcommand.Elm(cmd.subcommand), cmd.verbosity)}
private lazy val elmMake: Command[CliCommand[Subcommand.ElmMake]] = Command("make", verbosityFlag).map{ v => CliCommand(Subcommand.ElmMake(), v)}
private lazy val elmGen: Command[CliCommand[Subcommand.ElmGen]] = Command("gen", verbosityFlag).map{ v => CliCommand(Subcommand.ElmGen(), v)}
lazy val make = Command("make", verbosityFlag).map{v => CliCommand(Subcommand.Make(), v)}
lazy val verbosityFlag = Options
.enumeration("verbosity")("quiet" -> Verbosity.Quiet, "normal" -> Verbosity.Normal, "verbose" -> Verbosity.Verbose)
.alias("v")
.withDefault(Verbosity.Normal)
lazy val elm: Command[CliCommand[Subcommand.Elm]] =
Command("elm").subcommands(elmMake, elmGen).map(cmd => CliCommand(Subcommand.Elm(cmd.subcommand), cmd.verbosity))
private lazy val elmMake: Command[CliCommand[Subcommand.ElmMake]] = Command("make", verbosityFlag).map { v =>
CliCommand(Subcommand.ElmMake(), v)
}
private lazy val elmGen: Command[CliCommand[Subcommand.ElmGen]] = Command("gen", verbosityFlag).map { v =>
CliCommand(Subcommand.ElmGen(), v)
}
lazy val make = Command("make", verbosityFlag).map(v => CliCommand(Subcommand.Make(), v))

def morphir(commandName:String = "morphir") = Command(name = commandName).subcommands(elm, make)
def morphir(commandName: String = "morphir") = Command(name = commandName).subcommands(elm, make)
}

sealed trait Verbosity extends Product with Serializable
object Verbosity{
case object Quiet extends Verbosity
case object Normal extends Verbosity
object Verbosity {
case object Quiet extends Verbosity
case object Normal extends Verbosity
case object Verbose extends Verbosity
}
}
12 changes: 6 additions & 6 deletions morphir-cli/src/main/scala/zio/morphir/main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ object Main extends ZIOAppDefault {
version = "0.1.0",
summary = text("Morphir is a command line tool for creating and running morphir IRs."),
command = CliCommand.morphir()
){
case cmd @ CliCommand(Subcommand.Elm(Subcommand.ElmMake()),_) =>
) {
case cmd @ CliCommand(Subcommand.Elm(Subcommand.ElmMake()), _) =>
for {
_ <- printLine("Running morphir elm make tooling...")
_ <- printLine(s"Command: ${cmd}")
_ <- printLine("TODO: Implement morphir elm make tooling")
_ <- printLine("Done.")
} yield ()

case cmd @ CliCommand(Subcommand.Elm(Subcommand.ElmGen()),_) =>
case cmd @ CliCommand(Subcommand.Elm(Subcommand.ElmGen()), _) =>
for {
_ <- printLine("Running morphir elm gen tooling...")
_ <- printLine(s"Command: ${cmd}")
_ <- printLine("TODO: Implement morphir elm gen tooling")
_ <- printLine("Done.")
} yield ()
case cmd @ CliCommand(CliCommand.Subcommand.Elm(_),_) =>
case cmd @ CliCommand(CliCommand.Subcommand.Elm(_), _) =>
for {
_ <- printLine("Running morphir elm tooling...")
_ <- printLine(s"Command: ${cmd}")
_ <- printLine("TODO: Implement morphir elm tooling")
_ <- printLine("Done.")
} yield ()
case cmd @ CliCommand(CliCommand.Subcommand.Make(),_) =>
case cmd @ CliCommand(CliCommand.Subcommand.Make(), _) =>
for {
_ <- printLine("Running morphir make tooling...")
_ <- printLine(s"Command: ${cmd}")
Expand All @@ -51,6 +51,6 @@ object Main extends ZIOAppDefault {

def run = for {
args <- ZIOAppArgs.getArgs
_ <- app.run(args.toList)
_ <- app.run(args.toList)
} yield ()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ object Extractors {

def apply(using Quotes)(expr: Expr[_]): Expr[_] =
import quotes.reflect._
import scala.util.{ Try, Success, Failure }
import scala.util.{Try, Success, Failure}
Untype.unapply(expr.asTerm).map(_.asExpr).get
}

// Always match (whether ast starts with Typed or not). If it does, strip the Typed node.
object Untype {
def unapply(using Quotes)(term: quotes.reflect.Term): Option[quotes.reflect.Term] = term match {
case TypedMatroshkaTerm(t) => Some(t)
case other => Some(other)
case other => Some(other)
}

def apply(using Quotes)(term: quotes.reflect.Term) = Untype.unapply(term).get
Expand All @@ -33,18 +33,18 @@ object Extractors {
import quotes.reflect._
innerTerm match
case Typed(innerTree, _) => recurse(innerTree)
case other => other
case other => other

def unapply(using Quotes)(term: quotes.reflect.Term): Option[quotes.reflect.Term] =
import quotes.reflect._
term match
case Typed(tree, _) => Some(recurse(tree))
case other => None
case other => None
}

object TypedMatroshka {
def unapply(using Quotes)(term: Expr[Any]): Option[Expr[Any]] =
import quotes.reflect._
TypedMatroshkaTerm.unapply(term.asTerm).map(_.asExpr)
}
}
}
Loading