Created
October 2, 2013 03:05
-
-
Save mxswd/6788583 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import System.IO | |
import System.Exit | |
import System.Process | |
import System.Environment | |
main :: IO () | |
main = do | |
args <- getArgs | |
mapSystem $ fmap (map (\x -> "/bin/bash -c '" ++ x ++ "'")) $ case args of | |
[] -> Right ["cabal configure", "cabal build"] | |
["deps"] -> Right ["cabal install --only-dependencies"] | |
["install"] -> Right ["cabal install"] | |
["test"] -> Right ["cabal configure --enable-tests", "cabal build", "cabal test"] | |
_ -> Left "usage: cake [_,deps,install,test]" | |
mapSystem :: Either String [String] -> IO () | |
mapSystem (Left x) = hPutStrLn stderr x | |
mapSystem (Right ([])) = return () | |
mapSystem (Right (h:xs)) = do | |
x <- system h | |
case x of | |
ExitSuccess -> mapSystem (Right xs) | |
c -> exitWith c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment