@@ -0,0 +1,33 @@
1+module Text.Hakyll
2+ ( hakyll
3+ ) where
4+
5+import System.Environment (getArgs, getProgName)
6+import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
7+
8+-- | Main function to run hakyll.
9+hakyll :: IO () -> IO ()
10+hakyll action = do
11+ args <- getArgs
12+ case args of [] -> action
13+ ["--clean"] -> clean
14+ _ -> showHelp
15+
16+clean :: IO ()
17+clean = do remove' "_cache"
18+ remove' "_site"
19+ where remove' dir = do exists <- doesDirectoryExist dir
20+ if exists then removeDirectoryRecursive dir
21+ else return ()
22+
23+-- | Show usage information.
24+showHelp :: IO ()
25+showHelp = do
26+ name <- getProgName
27+ putStrLn $ "This is a hakyll site generator program. You should always run\n"
28+ ++ "it from the project root directory.\n"
29+ ++ "\n"
30+ ++ "Usage:\n"
31+ ++ name ++ " Generate the site.\n"
32+ ++ name ++ " --clean Clean up and remove cache.\n"
33+ ++ name ++ " --help Show this message.\n"