summaryrefslogtreecommitdiff
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
parent2648115e87f9ad87571b4199cc3b642b0c8079c7 (diff)
downloadhakyll-9608a9bde5cf490788809609425d890a814f7b75.tar.gz
Added main method/module.
-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"