From 2819b7fc57cb64168888ee7e1af13872178fa7ce Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Mon, 9 Dec 2024 20:19:31 -0500 Subject: [PATCH] Take in input/output file args --- src/Main.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index af31a6d..ced6c16 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -6,10 +6,17 @@ import qualified Data.Text.IO as T import Data.Text.Prettyprint.Doc (pretty) import Text.Megaparsec (parse) import Windows12.Parser (programP) +import System.Environment (getArgs) main :: IO () main = do - test <- T.readFile "test/hello.w12" - case parse programP "test/hello.w12" test of - Left err -> print err - Right ast -> print (pretty ast) + args <- getArgs + + if length args /= 2 + then putStrLn "Usage: windows12 " + else do + let [inputFile, outputFile] = args + test <- T.readFile inputFile + case parse programP inputFile test of + Left err -> print err + Right ast -> print (pretty ast)