summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-27 00:01:35 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-27 00:01:35 +0100
commit9608a9bde5cf490788809609425d890a814f7b75 (patch)
treee0aa0579d01bc34c6fc563b7f16effdb03d0daed /src/Text/Hakyll.hs
parent2648115e87f9ad87571b4199cc3b642b0c8079c7 (diff)
downloadhakyll-9608a9bde5cf490788809609425d890a814f7b75.tar.gz
Added main method/module.
Diffstat (limited to 'src/Text/Hakyll.hs')
-rw-r--r--src/Text/Hakyll.hs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Text/Hakyll.hs b/src/Text/Hakyll.hs
new file mode 100644
index 0000000..6e85907
--- /dev/null
+++ b/src/Text/Hakyll.hs
@@ -0,0 +1,33 @@
+module Text.Hakyll
+ ( hakyll
+ ) where
+
+import System.Environment (getArgs, getProgName)
+import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
+
+-- | Main function to run hakyll.
+hakyll :: IO () -> IO ()
+hakyll action = do
+ args <- getArgs
+ case args of [] -> action
+ ["--clean"] -> clean
+ _ -> showHelp
+
+clean :: IO ()
+clean = do remove' "_cache"
+ remove' "_site"
+ where remove' dir = do exists <- doesDirectoryExist dir
+ if exists then removeDirectoryRecursive dir
+ else return ()
+
+-- | Show usage information.
+showHelp :: IO ()
+showHelp = do
+ name <- getProgName
+ putStrLn $ "This is a hakyll site generator program. You should always run\n"
+ ++ "it from the project root directory.\n"
+ ++ "\n"
+ ++ "Usage:\n"
+ ++ name ++ " Generate the site.\n"
+ ++ name ++ " --clean Clean up and remove cache.\n"
+ ++ name ++ " --help Show this message.\n"