shake.hs 946 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#! /usr/bin/env runhaskell

import           Development.Shake
import           Development.Shake.FilePath
import           Control.Monad

main = shakeArgs shakeOptions $ do
  phony "clean" $ do
    removeFilesAfter "completion" ["//*"]
    removeFilesAfter "." ["README.md"]

  want ["README.md", "completion/argotk.sh"]

  "completion/*.sh"
Valentin Reis's avatar
Valentin Reis committed
15
    %> \out -> mkCompletionRule out "bash" $ takeFileName out -<.> "hs"
16 17 18

  "README.md" %> \out -> do
    let template = ".README.md"
Valentin Reis's avatar
Valentin Reis committed
19
    need [template , "argotk/argotk.hs" , "argo/src/Argo/Stack.hs"]
20 21 22 23 24
    (Stdout panpipe) <- cmd "which panpipe"
    cmd_ "pandoc --filter"
         [take (length panpipe - 1) panpipe, template, "-o", out]
 where
  mkCompletionAction str sn =
25
    (sn, cmd ("argotk/" ++ sn) ["--" ++ str ++ "-completion-script", sn])
26 27 28 29
  mkCompletionRule out str fn = do
    let (needed, cplA) = mkCompletionAction str fn
    (Stdout cplScript) <- cplA
    liftIO $ writeFile out cplScript