Set up compiler project

This commit is contained in:
Aly 2020-09-18 13:52:46 -07:00
parent 8b8e09e3b6
commit 5ca6a1eb60
3 changed files with 63 additions and 5 deletions

View file

@ -107,6 +107,14 @@ object recipe extends TpolecatModule with PublishModule {
), ),
) )
override def ivyDeps = Agg(
ivy"org.typelevel::cats-effect:2.2.0",
ivy"co.fs2::fs2-core:2.4.3",
ivy"co.fs2::fs2-io:2.4.3",
ivy"com.monovore::decline:1.3.0",
ivy"com.monovore::decline-effect:1.3.0",
)
override def moduleDeps = Seq(tagless, scodec) override def moduleDeps = Seq(tagless, scodec)
override def scalacPluginIvyDeps = Agg(ivy"org.typelevel:::kind-projector:0.11.0", ivy"com.olegpy::better-monadic-for:0.3.1") override def scalacPluginIvyDeps = Agg(ivy"org.typelevel:::kind-projector:0.11.0", ivy"com.olegpy::better-monadic-for:0.3.1")

View file

@ -1,5 +0,0 @@
package tf.bug.fancade.recipe
object Bar {
}

View file

@ -0,0 +1,55 @@
package tf.bug.fancade.recipe
import cats.implicits._
import com.monovore.decline.effect.CommandIOApp
import cats.effect.{ExitCode, IO}
import com.monovore.decline.Opts
import java.nio.file.Path
import com.monovore.decline.Argument
object Main extends CommandIOApp(
name = "fancade-recipe",
header = "Fancade recipe creator and format helper",
version = "2.0.0",
) {
sealed trait InFormat
object InFormat {
implicit val arg: Argument[InFormat] = Argument.fromMap("input-format", Map(
"json" -> FancadeStackJson,
"fcl" -> FancadeLisp,
))
}
sealed trait OutFormat
object OutFormat {
implicit val arg: Argument[OutFormat] = Argument.fromMap("output-format", Map(
"json" -> FancadeStackJson,
"txt" -> Recipe,
"bin" -> Level,
))
}
case object FancadeStackJson extends InFormat with OutFormat
case object FancadeLisp extends InFormat
case object Recipe extends OutFormat
case object Level extends OutFormat
case class Compile(in: InFormat, inFile: Path, out: OutFormat, outFile: Path)
val compileOpts = {
val inFormatOpts = Opts.argument[InFormat]("input-format")
val inFileOpts = Opts.argument[Path]("input-path")
val outFormatOpts = Opts.argument[OutFormat]("output-format")
val outFileOpts = Opts.argument[Path]("output-path")
Opts.subcommand("compile", "Converts between script formats") {
(inFormatOpts, inFileOpts, outFormatOpts, outFileOpts).mapN(Compile)
}
}
override def main: Opts[IO[ExitCode]] = compileOpts.map {
case Compile(in, _, out, _) =>
IO(println(s"hello $in $out")).as(ExitCode.Success)
}
}