Skip to content


Subversion checkout URL

You can clone with
Download ZIP
tree: ff46de28b5
Fetching contributors…

Cannot retrieve contributors at this time

executable file 82 lines (76 sloc) 3.026 kB
import Scaffolding.Scaffolder
import System.Environment (getArgs)
import System.Exit (exitWith, ExitCode (ExitSuccess))
import System.Process (rawSystem)
import Yesod.Core (yesodVersion)
import Control.Monad (unless)
import qualified Paths_yesod
import Data.Version (showVersion)
#ifndef WINDOWS
import Build (touch)
import Devel (devel)
import AddHandler (addHandler)
import Keter (keter)
windowsWarning :: String
#ifdef WINDOWS
windowsWarning = "\n (does not work on Windows)"
windowsWarning = ""
main :: IO ()
main = do
args' <- getArgs
let (isDev, args) =
case args' of
"--dev":rest -> (True, rest)
_ -> (False, args')
let cmd = if isDev then "cabal-dev" else "cabal"
#ifndef WINDOWS
let build rest = rawSystem cmd $ "build":rest
case args of
["init"] -> scaffold
#ifndef WINDOWS
"build":rest -> touch >> build rest >>= exitWith
["touch"] -> touch
"devel":rest -> devel isDev rest
"test":_ -> do
#ifndef WINDOWS
rawSystem' cmd ["configure", "--enable-tests", "-flibrary-only"]
rawSystem' cmd ["build"]
rawSystem' cmd ["test"]
["version"] -> do
putStrLn $ "yesod-core version:" ++ yesodVersion
putStrLn $ "yesod version:" ++ showVersion Paths_yesod.version
"configure":rest -> rawSystem cmd ("configure":rest) >>= exitWith
["add-handler"] -> addHandler
["keter"] -> keter cmd False
["keter", "--nobuild"] -> keter cmd True
_ -> do
putStrLn "Usage: yesod <command>"
putStrLn "Available commands:"
putStrLn " init Scaffold a new site"
putStrLn " configure Configure a project for building"
putStrLn $ " build Build project (performs TH dependency analysis)"
++ windowsWarning
putStrLn $ " touch Touch any files with altered TH dependencies but do not build"
++ windowsWarning
putStrLn " devel Run project with the devel server"
putStrLn " use --dev devel to build with cabal-dev"
putStrLn " test Build and run the integration tests"
putStrLn " use --dev devel to build with cabal-dev"
putStrLn " add-handler Add a new handler and module to your project"
putStrLn " keter Build a keter bundle"
putStrLn " use --dev devel to build with cabal-dev"
putStrLn " use --nobuild to skip rebuilding"
putStrLn " version Print the version of Yesod"
-- | Like @rawSystem@, but exits if it receives a non-success result.
rawSystem' :: String -> [String] -> IO ()
rawSystem' x y = do
res <- rawSystem x y
unless (res == ExitSuccess) $ exitWith res
Jump to Line
Something went wrong with that request. Please try again.