on master help sign in
Added main method/module.
9608a9bJasper Van der Jeugt
hakyll.cabal+2−1
@@ -20,7 +20,8 @@ library
20 hs-source-dirs: src/
20 hs-source-dirs: src/
21 build-depends: base >= 4 && < 5, template, filepath, directory, containers, bytestring,
21 build-depends: base >= 4 && < 5, template, filepath, directory, containers, bytestring,
22 pandoc >= 1, regex-compat
22 pandoc >= 1, regex-compat
23− exposed-modules: Text.Hakyll.Render
23+ exposed-modules: Text.Hakyll
24+ Text.Hakyll.Render
24 Text.Hakyll.Renderable
25 Text.Hakyll.Renderable
25 Text.Hakyll.Renderables
26 Text.Hakyll.Renderables
26 Text.Hakyll.CompressCSS
27 Text.Hakyll.CompressCSS
src/Text/Hakyll.hsnew file+33
@@ -0,0 +1,33 @@
1+module Text.Hakyll
2+ ( hakyll
3+ ) where
4+
5+import System.Environment (getArgs, getProgName)
6+import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
7+
8+-- | Main function to run hakyll.
9+hakyll :: IO () -> IO ()
10+hakyll action = do
11+ args <- getArgs
12+ case args of [] -> action
13+ ["--clean"] -> clean
14+ _ -> showHelp
15+
16+clean :: IO ()
17+clean = do remove' "_cache"
18+ remove' "_site"
19+ where remove' dir = do exists <- doesDirectoryExist dir
20+ if exists then removeDirectoryRecursive dir
21+ else return ()
22+
23+-- | Show usage information.
24+showHelp :: IO ()
25+showHelp = do
26+ name <- getProgName
27+ putStrLn $ "This is a hakyll site generator program. You should always run\n"
28+ ++ "it from the project root directory.\n"
29+ ++ "\n"
30+ ++ "Usage:\n"
31+ ++ name ++ " Generate the site.\n"
32+ ++ name ++ " --clean Clean up and remove cache.\n"
33+ ++ name ++ " --help Show this message.\n"