aboutsummaryrefslogtreecommitdiff
path: root/app/Main.hs
diff options
context:
space:
mode:
authorevuez <julien@mulga.net>2024-04-01 15:16:52 +0200
committerevuez <julien@mulga.net>2024-04-03 22:45:16 +0200
commitff174d9536db26945189593bf8194f18fbd5ce3f (patch)
tree327cf783e3c24a0b4b035f548b0ea7206ea9b0f9 /app/Main.hs
downloaduncron-ff174d9536db26945189593bf8194f18fbd5ce3f.tar.gz
Initial commit
Diffstat (limited to 'app/Main.hs')
-rw-r--r--app/Main.hs23
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. " ++)