From d214723f3560544227ca6578c75f2fc3b8f52000 Mon Sep 17 00:00:00 2001 From: Jonny Date: Fri, 28 Feb 2025 19:36:22 +0000 Subject: [PATCH] feat: parallelise compilation of multiple files given to cli --- src/main/wacc/Main.scala | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/wacc/Main.scala b/src/main/wacc/Main.scala index ef4575c..35479bd 100644 --- a/src/main/wacc/Main.scala +++ b/src/main/wacc/Main.scala @@ -16,11 +16,6 @@ import com.monovore.decline.Argument import assemblyIR as asm - -case class CliConfig( - file: File = new File(".") -) - given Argument[File] = Argument.from("file") { str => val file = File(str) ( @@ -94,11 +89,14 @@ object Main version = "1.0" ) { def main: Opts[IO[ExitCode]] = - Opts.argument[File]("file").map { file => - compile( - file.getAbsolutePath, - outFile = Some(File(".", file.getName.stripSuffix(".wacc") + ".s")) - ).map(ExitCode(_)) // turn the int into exit code for compatibility with commandioapp - // https://ben.kirw.in/decline/effect.html + Opts.arguments[File]("files").map { files => + files + .parTraverse_ { file => + compile( + file.getAbsolutePath, + outFile = Some(File(".", file.getName.stripSuffix(".wacc") + ".s")) + ) + } + .as(ExitCode.Success) } }