module Main where

import qualified Data.Text.IO as TIO

import Options.Applicative

import Deck.Diff
import Parser
import Repr.DiffRep
import Repr.Interpret

diffP :: Parser (String, String)
diffP = (,) <$> strArgument (metavar "OLDFILE") <*> strArgument (metavar "NEWFILE")

runParser :: IO (String, String)
runParser = execParser opts
  where
    opts = info (diffP <**> helper) fullDesc

main :: IO ()
main = do
    (oldFile, newFile) <- runParser
    res <- readDiffFiles oldFile newFile

    case res of
        Left e -> print e
        Right (old, new) ->
            do
                let diffDeck = diff old new
                TIO.putStrLn . view . evalMany $ diffDeck

    return ()