Take in input/output file args
This commit is contained in:
parent
37cf2fe339
commit
2819b7fc57
15
src/Main.hs
15
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 <input file> <output file>"
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user