summaryrefslogtreecommitdiff
path: root/src/Hakyll/Init.hs
blob: d50c6f6f1f8fe2dc8479db27f1c92490f64aee31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--------------------------------------------------------------------------------
module Main
    ( main
    ) where


--------------------------------------------------------------------------------
import           Control.Monad         (forM_)
import           System.Directory      (copyFile)
import           System.Environment    (getArgs, getProgName)
import           System.Exit           (exitFailure)
import           System.FilePath       ((</>))


--------------------------------------------------------------------------------
import           Hakyll.Core.Util.File
import           Paths_hakyll


--------------------------------------------------------------------------------
main :: IO ()
main = do
    progName <- getProgName
    args     <- getArgs
    srcDir   <- getDataFileName "example"
    files    <- getRecursiveContents (const $ return False) 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