summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorErik Dominikus <haskell@edom.web.id>2015-04-26 16:04:14 +0700
committerJasper Van der Jeugt <m@jaspervdj.be>2015-04-30 17:16:45 +0200
commit0eb8a8b4ff2e30ef41d6b9fba2de70d3b9fb3347 (patch)
tree340b1a5931eed5bfa44d67540b90126c2f75cd72 /src
parent44ddbc3fd6d58e0bba0526d7d7382930d87cd239 (diff)
downloadhakyll-0eb8a8b4ff2e30ef41d6b9fba2de70d3b9fb3347.tar.gz
Let caller decide exit
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Main.hs29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/Hakyll/Main.hs b/src/Hakyll/Main.hs
index 1deb93a..86c3245 100644
--- a/src/Hakyll/Main.hs
+++ b/src/Hakyll/Main.hs
@@ -5,6 +5,7 @@
module Hakyll.Main
( hakyll
, hakyllWith
+ , hakyllWithExitCode
) where
@@ -13,7 +14,7 @@ import System.Console.CmdArgs
import qualified System.Console.CmdArgs.Explicit as CA
import System.Environment (getProgName)
import System.IO.Unsafe (unsafePerformIO)
-import System.Exit (exitWith)
+import System.Exit (ExitCode(ExitSuccess), exitWith)
--------------------------------------------------------------------------------
import qualified Hakyll.Check as Check
@@ -28,12 +29,14 @@ import Hakyll.Core.Rules
hakyll :: Rules a -> IO ()
hakyll = hakyllWith Config.defaultConfiguration
-
--------------------------------------------------------------------------------
-- | A variant of 'hakyll' which allows the user to specify a custom
-- configuration
hakyllWith :: Config.Configuration -> Rules a -> IO ()
-hakyllWith conf rules = do
+hakyllWith conf rules = hakyllWithExitCode conf rules >>= exitWith
+
+hakyllWithExitCode :: Config.Configuration -> Rules a -> IO ExitCode
+hakyllWithExitCode conf rules = do
args' <- cmdArgs (hakyllArgs conf)
let verbosity' = if verbose args' then Logger.Debug else Logger.Message
@@ -42,15 +45,17 @@ hakyllWith conf rules = do
logger <- Logger.new verbosity'
case args' of
- Build _ -> Commands.build conf logger rules >>= exitWith
- Check _ _ -> Commands.check conf logger check'
- Clean _ -> Commands.clean conf logger
- Deploy _ -> Commands.deploy conf >>= exitWith
- Help _ -> showHelp
- Preview _ p -> Commands.preview conf logger rules p
- Rebuild _ -> Commands.rebuild conf logger rules >>= exitWith
- Server _ _ _ -> Commands.server conf logger (host args') (port args')
- Watch _ _ p s -> Commands.watch conf logger (host args') p (not s) rules
+ Build _ -> Commands.build conf logger rules
+ Check _ _ -> Commands.check conf logger check' >> ok
+ Clean _ -> Commands.clean conf logger >> ok
+ Deploy _ -> Commands.deploy conf
+ Help _ -> showHelp >> ok
+ Preview _ p -> Commands.preview conf logger rules p >> ok
+ Rebuild _ -> Commands.rebuild conf logger rules
+ Server _ _ _ -> Commands.server conf logger (host args') (port args') >> ok
+ Watch _ _ p s -> Commands.watch conf logger (host args') p (not s) rules >> ok
+ where
+ ok = return ExitSuccess
--------------------------------------------------------------------------------