summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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"