module Main where

import Evaluation (run)
import Parser (parse)
import System.Environment (getArgs)
import System.IO (IOMode (ReadMode), hGetContents, openFile)

main :: IO ()
main = do
  args <- getArgs

  let command = args !! 0
  let path = args !! 1

  case command of
    "run" -> do
      content <- openFile path ReadMode >>= hGetContents
      either putStrLn putStrLn $ show . run <$> parse content
    _ -> putStrLn $ "Unrecognized command: " ++ command
