From 9608a9bde5cf490788809609425d890a814f7b75 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 27 Dec 2009 00:01:35 +0100 Subject: Added main method/module. --- src/Text/Hakyll.hs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/Text/Hakyll.hs (limited to 'src/Text/Hakyll.hs') 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" -- cgit v1.2.3