diff options
author | Vincent Ambo <tazjin@gmail.com> | 2015-11-19T17·31+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2015-11-19T17·31+0100 |
commit | 0f6ff6310ed93b6221120f23ec085c1b7951de5b (patch) | |
tree | 5fa5217906701b7a32c0b916370e72680892ba97 /blog | |
parent | 71b2ccd9275bacc789bce7f94d5792a24598460b (diff) |
[5.0-beta] Split into library and executable
Diffstat (limited to 'blog')
-rw-r--r-- | blog/Main.hs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/blog/Main.hs b/blog/Main.hs new file mode 100644 index 000000000000..a50ca67ed17d --- /dev/null +++ b/blog/Main.hs @@ -0,0 +1,38 @@ +module Main where + +import Control.Applicative (pure, (<$>), (<*>)) +import Control.Exception (bracket) +import Data.Acid +import Data.Acid.Local (createCheckpointAndClose) +import Options + +import BlogDB (initialBlogState) +import Locales (version) +import Server + +{- Server -} + +data MainOptions = MainOptions { + optState :: String, + optPort :: Int, + optRes :: String +} + +instance Options MainOptions where + defineOptions = pure MainOptions + <*> simpleOption "statedir" "/var/tazblog/" + "Directory in which the BlogState is located." + <*> simpleOption "port" 8000 + "Port to run on. Default is 8000." + <*> simpleOption "res" "/usr/share/tazblog/res" + "Resources folder location." + +main :: IO() +main = do + putStrLn ("TazBlog " ++ version ++ " in Haskell starting") + runCommand $ \opts args -> + bracket (openLocalStateFrom (optState opts ++ "BlogState") initialBlogState) + createCheckpointAndClose + (\acid -> runBlog acid (optPort opts) (optRes opts)) + + |