shake.hs 932 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"
15
    %> \out -> mkCompletionRule out "bash" $ "argotk" </> takeFileName out -<.> "hs"
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

  "README.md" %> \out -> do
    let template = ".README.md"
    need [template]
    (Stdout panpipe) <- cmd "which panpipe"
    cmd_ "pandoc --filter"
         [take (length panpipe - 1) panpipe, template, "-o", out]
 where
  mkCompletionAction str sn =
    (sn, cmd ("./" ++ sn) ["--" ++ str ++ "-completion-script", "." </> sn])
  mkCompletionRule out str fn = do
    let (needed, cplA) = mkCompletionAction str fn
    need [needed]
    (Stdout cplScript) <- cplA
    liftIO $ writeFile out cplScript