summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Hakyll/Init.hs24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/Hakyll/Init.hs b/src/Hakyll/Init.hs
index 974cacb..3e2969e 100644
--- a/src/Hakyll/Init.hs
+++ b/src/Hakyll/Init.hs
@@ -5,7 +5,11 @@ module Main
--------------------------------------------------------------------------------
+import Control.Monad (forM_)
import System.Directory (copyFile)
+import System.Environment (getArgs, getProgName)
+import System.Exit (exitFailure)
+import System.FilePath ((</>))
--------------------------------------------------------------------------------
@@ -16,8 +20,18 @@ import Paths_hakyll
--------------------------------------------------------------------------------
main :: IO ()
main = do
- let dstDir = "."
- srcDir <- getDataFileName "example"
- files <- getRecursiveContents srcDir
- print files
- return ()
+ progName <- getProgName
+ args <- getArgs
+ srcDir <- getDataFileName "example"
+ files <- getRecursiveContents srcDir
+
+ case args of
+ [dstDir] -> forM_ files $ \file -> do
+ let dst = dstDir </> file
+ src = srcDir </> file
+ putStrLn $ "Creating " ++ dst
+ makeDirectories dst
+ copyFile src dst
+ _ -> do
+ putStrLn $ "Usage: " ++ progName ++ " <directory>"
+ exitFailure