diff options
Diffstat (limited to 'app/Main.hs')
-rw-r--r-- | app/Main.hs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..0b1f81e --- /dev/null +++ b/app/Main.hs @@ -0,0 +1,23 @@ +module Main (main) where + +import Control.Arrow (left) +import qualified Cron +import Intro +import System.Environment (getArgs) +import System.IO (getLine) + +main :: IO () +main = do + cron <- getCron + putStrLn . showOrErr $ Cron.toProse <$> (Cron.parse =<< cron) + +getCron :: IO (Either String String) +getCron = do + args <- getArgs + case args of + [] -> Right <$> getLine + [x] -> pure $ Right x + xs -> pure $ Left ("Too many inputs or invalid option: " ++ show xs) + +showOrErr :: Either String String -> String +showOrErr = either id id . left ("Error. " ++) |