configure and build, using command line

This commit is contained in:
Michael Snoyman 2011-07-17 21:04:26 +03:00
parent ea51828143
commit c9eaf84694
3 changed files with 20 additions and 8 deletions

View File

@ -1,7 +1,6 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module Scaffold.Build module Scaffold.Build
( build ( touch
, touch
, getDeps , getDeps
, touchDeps , touchDeps
, findHaskellFiles , findHaskellFiles

View File

@ -43,8 +43,10 @@ swapApp i f = do
I.readIORef i >>= killThread I.readIORef i >>= killThread
f >>= I.writeIORef i f >>= I.writeIORef i
devel :: IO () devel :: ([String] -> IO ()) -- ^ configure command
devel = do -> ([String] -> IO ()) -- ^ build command
-> IO ()
devel conf build = do
e <- doesFileExist "dist/devel-flag" e <- doesFileExist "dist/devel-flag"
when e $ removeFile "dist/devel-flag" when e $ removeFile "dist/devel-flag"
listenThread <- forkIO (appMessage "Initializing, please wait") >>= I.newIORef listenThread <- forkIO (appMessage "Initializing, please wait") >>= I.newIORef

View File

@ -13,9 +13,11 @@ import qualified Data.Text.Lazy.Encoding as LT
import Control.Monad (when, unless) import Control.Monad (when, unless)
import System.Environment (getArgs) import System.Environment (getArgs)
import Scaffold.Build (build, touch) import Scaffold.Build (touch)
import Scaffold.Devel (devel) import Scaffold.Devel (devel)
import System.Process (rawSystem)
qq :: String qq :: String
#if __GLASGOW_HASKELL__ >= 700 #if __GLASGOW_HASKELL__ >= 700
qq = "" qq = ""
@ -34,16 +36,25 @@ prompt f = do
main :: IO () main :: IO ()
main = do main = do
args <- getArgs args' <- getArgs
let (isDev, args) =
case args' of
"--dev":rest -> (True, rest)
_ -> (False, args')
let cmd = if isDev then "cabal-dev" else "cabal"
let conf rest = rawSystem cmd ("configure":rest) >> return ()
let build rest = rawSystem cmd ("build":rest) >> return ()
case args of case args of
["init"] -> scaffold ["init"] -> scaffold
["build"] -> build "build":rest -> touch >> build rest
["touch"] -> touch ["touch"] -> touch
["devel"] -> devel ["devel"] -> devel conf build
"configure":rest -> conf rest
_ -> do _ -> do
putStrLn "Usage: yesod <command>" putStrLn "Usage: yesod <command>"
putStrLn "Available commands:" putStrLn "Available commands:"
putStrLn " init Scaffold a new site" putStrLn " init Scaffold a new site"
putStrLn " configure Configure a project for building"
putStrLn " build Build project (performs TH dependency analysis)" putStrLn " build Build project (performs TH dependency analysis)"
putStrLn " touch Touch any files with altered TH dependencies but do not build" putStrLn " touch Touch any files with altered TH dependencies but do not build"
putStrLn " devel Run project with the devel server" putStrLn " devel Run project with the devel server"