{-# LANGUAGE GADTs #-}
module Main where

import Control.Monad (liftM, unless)
import Data.List.Split (splitOn)
import System.IO (Handle, isEOF, hFlush, stdout)
import System.Process (readProcess)

import Shell.Parser (parse)
import Shell.Command (handleError, execute)

main :: IO ()
main = loop


loop :: IO ()
loop =  do
        hFlush stdout
        unlessFinished $ liftM (handleError . parse) getLine >>= execute >> loop
    where
    unlessFinished action = isEOF >>= flip unless action
