module Main where import qualified Data.Text.IO as T import Parser import Repl import System.Environment import System.IO main :: IO () main = do args <- getArgs case args of [] -> repl [file] -> handleFile file _ -> putStrLn "usage './perga' for repl and './perga ' to get input from a file" handleFile :: String -> IO () handleFile fileName = do fileH <- openFile fileName ReadMode input <- T.hGetContents fileH case pAll input of Left err -> putStrLn err Right () -> putStrLn "success!"