on master help sign in
Added main method/module.
commit9608a9bde5cf490788809609425d890a814f7b75 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSun 27 Dec 2009, 00:01 (17 years ago) parent2648115
2 files changed+35−1
hakyll.cabal+2−1 src/Text/Hakyll.hs+33
hakyll.cabal+2−1
@@ -20,7 +20,8 @@ library
2020 hs-source-dirs: src/
2121 build-depends: base >= 4 && < 5, template, filepath, directory, containers, bytestring,
2222 pandoc >= 1, regex-compat
23− exposed-modules: Text.Hakyll.Render
23+ exposed-modules: Text.Hakyll
24+ Text.Hakyll.Render
2425 Text.Hakyll.Renderable
2526 Text.Hakyll.Renderables
2627 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"