diff --git a/build.sc b/build.sc index 0b15473..a88f469 100644 --- a/build.sc +++ b/build.sc @@ -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 scalacPluginIvyDeps = Agg(ivy"org.typelevel:::kind-projector:0.11.0", ivy"com.olegpy::better-monadic-for:0.3.1") diff --git a/recipe/src/tf/bug/fancade/recipe/Bar.scala b/recipe/src/tf/bug/fancade/recipe/Bar.scala deleted file mode 100644 index dee01ad..0000000 --- a/recipe/src/tf/bug/fancade/recipe/Bar.scala +++ /dev/null @@ -1,5 +0,0 @@ -package tf.bug.fancade.recipe - -object Bar { - -} diff --git a/recipe/src/tf/bug/fancade/recipe/Main.scala b/recipe/src/tf/bug/fancade/recipe/Main.scala new file mode 100644 index 0000000..a7519a7 --- /dev/null +++ b/recipe/src/tf/bug/fancade/recipe/Main.scala @@ -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) + } + +}