From 3bd3fd2c6eae2f36f69f247403421e8cf8226394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Thu, 5 Sep 2013 19:57:02 -0300 Subject: Moved all code to src/ --- src/Main.hs | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/Main.hs (limited to 'src/Main.hs') diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..2144d9c --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,49 @@ +{- Main module + - + - Copyright 2013 Raúl Benencia + - + - Licensed under the GNU GPL version 3 or higher + - + -} + +module Main (main) where + +import Control.Monad.Reader(runReaderT) +import Control.Monad.State(runStateT) +import System.Environment +import System.Exit +import System.FilePath(takeDirectory) + +import Lazymail.Config(customConfig) +import Lazymail.Email +import Lazymail.Maildir +import Lazymail.Screen +import Lazymail.State +import Lazymail.Types + +parse ["-h"] = usage >> exit +parse ["--help"] = usage >> exit +parse ["-v"] = version >> exit +parse ["--version"] = version >> exit +parse _ = run entryPoint + +run :: Lazymail a -> IO (a, LazymailState) +run k = + let config = customConfig + state = initialState { basePath = initialPath config } + in runStateT (runReaderT k config) state + +usage = putStrLn . unlines $ usageText where + usageText = ["Usage: ./Main [-vh] " + ," where is a directory with Maildirs, or a Maildir itself." + ," Lazymail will recursively search for Maildirs. "] + +version = putStrLn "Haskell lazymail 0.0001" +exit = exitWith ExitSuccess +die = exitWith (ExitFailure 1) + +main :: IO () +main = do + args <- getArgs + parse args + putStrLn "Game over!" -- cgit v1.2.3