aboutsummaryrefslogtreecommitdiff
path: root/hypsrc-test/accept.hs
blob: 4606b2dfb0feb98975843a7807bf5b4ad32290d4 (plain) (blame)
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
#!/usr/bin/env runhaskell
{-# LANGUAGE CPP #-}


import System.Directory
import System.FilePath
import System.Environment

import Utils


main :: IO ()
main = do
    args <- getArgs
    files <- filter isHtmlFile <$> getDirectoryContents outDir'
    let files' = if args == ["--all"] || args == ["-a"]
        then files
        else filter ((`elem` args) . takeBaseName) files
    mapM_ copy files'
  where
    isHtmlFile = (== ".html") . takeExtension


copy :: FilePath -> IO ()
copy file = do
    content <- stripLocalReferences <$> readFile (outDir' </> file)
    writeFile (refDir' </> file) content