summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hakyll.cabal3
-rw-r--r--src/Text/Hakyll.hs33
2 files changed, 35 insertions, 1 deletions
diff --git a/hakyll.cabal b/hakyll.cabal
index 0f6d98e..ed1dfb4 100644
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -20,7 +20,8 @@ library
hs-source-dirs: src/
build-depends: base >= 4 && < 5, template, filepath, directory, containers, bytestring,
pandoc >= 1, regex-compat
- exposed-modules: Text.Hakyll.Render
+ exposed-modules: Text.Hakyll
+ Text.Hakyll.Render
Text.Hakyll.Renderable
Text.Hakyll.Renderables
Text.Hakyll.CompressCSS
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"