Skip to content

Instantly share code, notes, and snippets.

@mxswd
Created October 2, 2013 03:05
Show Gist options
  • Save mxswd/6788583 to your computer and use it in GitHub Desktop.
Save mxswd/6788583 to your computer and use it in GitHub Desktop.
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