diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-12-31 15:16:14 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-12-31 15:16:14 +0100 |
commit | 24273d034850b1312c551f6ace7f0b549728cbc9 (patch) | |
tree | c17c96c372a9605fb5081311d7a6d93de4135649 /src | |
parent | ed03544e1b58710448fa67764f10554b8eeab8dc (diff) | |
download | hakyll-24273d034850b1312c551f6ace7f0b549728cbc9.tar.gz |
Remove verbosity from configuration
Diffstat (limited to 'src')
-rw-r--r-- | src/Hakyll/Check.hs | 14 | ||||
-rw-r--r-- | src/Hakyll/Commands.hs | 28 | ||||
-rw-r--r-- | src/Hakyll/Core/Configuration.hs | 10 | ||||
-rw-r--r-- | src/Hakyll/Core/Runtime.hs | 8 | ||||
-rw-r--r-- | src/Hakyll/Main.hs | 21 |
5 files changed, 35 insertions, 46 deletions
diff --git a/src/Hakyll/Check.hs b/src/Hakyll/Check.hs index 232d510..5908310 100644 --- a/src/Hakyll/Check.hs +++ b/src/Hakyll/Check.hs @@ -30,16 +30,16 @@ import qualified Text.HTML.TagSoup as TS -------------------------------------------------------------------------------- import Hakyll.Core.Configuration -import Hakyll.Core.Logger (Logger) +import Hakyll.Core.Logger (Logger, Verbosity) import qualified Hakyll.Core.Logger as Logger import Hakyll.Core.Util.File import Hakyll.Web.Html -------------------------------------------------------------------------------- -check :: Configuration -> IO ExitCode -check config = do - ((), write) <- runChecker checkDestination config +check :: Configuration -> Verbosity -> IO ExitCode +check config verbosity = do + ((), write) <- runChecker checkDestination config verbosity return $ if checkerFaulty write >= 0 then ExitFailure 1 else ExitSuccess @@ -73,9 +73,9 @@ type Checker a = RWST CheckerRead CheckerWrite CheckerState IO a -------------------------------------------------------------------------------- -runChecker :: Checker a -> Configuration -> IO (a, CheckerWrite) -runChecker checker config = do - logger <- Logger.new (verbosity config) +runChecker :: Checker a -> Configuration -> Verbosity -> IO (a, CheckerWrite) +runChecker checker config verbosity = do + logger <- Logger.new verbosity let read' = CheckerRead config logger (x, _, write) <- runRWST checker read' S.empty Logger.flush logger diff --git a/src/Hakyll/Commands.hs b/src/Hakyll/Commands.hs index 88905ea..23deb7f 100644 --- a/src/Hakyll/Commands.hs +++ b/src/Hakyll/Commands.hs @@ -23,13 +23,13 @@ import System.Process (system) -------------------------------------------------------------------------------- import qualified Hakyll.Check as Check import Hakyll.Core.Configuration +import Hakyll.Core.Logger (Verbosity) import Hakyll.Core.Rules import Hakyll.Core.Runtime -------------------------------------------------------------------------------- #ifdef PREVIEW_SERVER -import Control.Applicative ((<$>)) import Control.Concurrent (forkIO) import qualified Data.Set as S import Hakyll.Core.Identifier @@ -41,16 +41,16 @@ import Hakyll.Preview.Server -------------------------------------------------------------------------------- -- | Build the site -build :: Configuration -> Rules a -> IO () -build conf rules = do - _ <- run conf rules +build :: Configuration -> Verbosity -> Rules a -> IO () +build conf verbosity rules = do + _ <- run conf verbosity rules return () -------------------------------------------------------------------------------- -- | Run the checker and exit -check :: Configuration -> IO () -check config = Check.check config >>= exitWith +check :: Configuration -> Verbosity -> IO () +check config verbosity = Check.check config verbosity >>= exitWith -------------------------------------------------------------------------------- @@ -68,27 +68,29 @@ clean conf = do -------------------------------------------------------------------------------- -- | Preview the site -preview :: Configuration -> Rules a -> Int -> IO () +preview :: Configuration -> Verbosity -> Rules a -> Int -> IO () #ifdef PREVIEW_SERVER -preview conf rules port = do +preview conf verbosity rules port = do -- Fork a thread polling for changes _ <- forkIO $ previewPoll conf update -- Run the server in the main thread server conf port where - update = map toFilePath . S.toList . rulesResources <$> run conf rules + update = do + ruleSet <- run conf verbosity rules + return $ map toFilePath $ S.toList $ rulesResources ruleSet #else -preview _ _ _ = previewServerDisabled +preview _ _ _ _ = previewServerDisabled #endif -------------------------------------------------------------------------------- -- | Rebuild the site -rebuild :: Configuration -> Rules a -> IO () -rebuild conf rules = do +rebuild :: Configuration -> Verbosity -> Rules a -> IO () +rebuild conf verbosity rules = do clean conf - build conf rules + build conf verbosity rules -------------------------------------------------------------------------------- diff --git a/src/Hakyll/Core/Configuration.hs b/src/Hakyll/Core/Configuration.hs index c45d1a3..86898dc 100644 --- a/src/Hakyll/Core/Configuration.hs +++ b/src/Hakyll/Core/Configuration.hs @@ -1,8 +1,7 @@ -------------------------------------------------------------------------------- -- | Exports a datastructure for the top-level hakyll configuration module Hakyll.Core.Configuration - ( Verbosity (..) - , Configuration (..) + ( Configuration (..) , shouldIgnoreFile , defaultConfiguration ) where @@ -14,10 +13,6 @@ import System.FilePath (normalise, takeFileName) -------------------------------------------------------------------------------- -import Hakyll.Core.Logger - - --------------------------------------------------------------------------------- data Configuration = Configuration { -- | Directory in which the output written destinationDirectory :: FilePath @@ -57,8 +52,6 @@ data Configuration = Configuration , -- | Use an in-memory cache for items. This is faster but uses more -- memory. inMemoryCache :: Bool - -- | Verbosity for the logger. Can be overwritten by the command-line. - , verbosity :: Verbosity } @@ -72,7 +65,6 @@ defaultConfiguration = Configuration , ignoreFile = ignoreFile' , deployCommand = "echo 'No deploy command specified'" , inMemoryCache = True - , verbosity = Message } where ignoreFile' path diff --git a/src/Hakyll/Core/Runtime.hs b/src/Hakyll/Core/Runtime.hs index 7e4a835..e052f37 100644 --- a/src/Hakyll/Core/Runtime.hs +++ b/src/Hakyll/Core/Runtime.hs @@ -28,7 +28,7 @@ import Hakyll.Core.Configuration import Hakyll.Core.Dependencies import Hakyll.Core.Identifier import Hakyll.Core.Item.SomeItem -import Hakyll.Core.Logger (Logger) +import Hakyll.Core.Logger (Logger, Verbosity) import qualified Hakyll.Core.Logger as Logger import Hakyll.Core.Provider import Hakyll.Core.Routes @@ -41,10 +41,10 @@ import Hakyll.Core.Writable -------------------------------------------------------------------------------- -- | TODO Make this return exit code? -run :: Configuration -> Rules a -> IO RuleSet -run config rules = do +run :: Configuration -> Verbosity -> Rules a -> IO RuleSet +run config verbosity rules = do -- Initialization - logger <- Logger.new (verbosity config) + logger <- Logger.new verbosity Logger.header logger "Initialising..." Logger.message logger "Creating store..." store <- Store.new (inMemoryCache config) $ storeDirectory config diff --git a/src/Hakyll/Main.hs b/src/Hakyll/Main.hs index e7f10ab..86aae28 100644 --- a/src/Hakyll/Main.hs +++ b/src/Hakyll/Main.hs @@ -35,21 +35,16 @@ hakyllWith :: Config.Configuration -> Rules a -> IO () hakyllWith conf rules = do args' <- cmdArgs hakyllArgs - -- Overwrite conf based on args - let conf' = conf - { Config.verbosity = - if verbose args' then Logger.Debug else Config.verbosity conf - } - + let verbosity' = if verbose args' then Logger.Debug else Logger.Message case args' of - Build _ -> Commands.build conf' rules - Check _ -> Commands.check conf' - Clean _ -> Commands.clean conf' - Deploy _ -> Commands.deploy conf' + Build _ -> Commands.build conf verbosity' rules + Check _ -> Commands.check conf verbosity' + Clean _ -> Commands.clean conf + Deploy _ -> Commands.deploy conf Help _ -> showHelp - Preview _ p -> Commands.preview conf' rules p - Rebuild _ -> Commands.rebuild conf' rules - Server _ _ -> Commands.server conf' (port args') + Preview _ p -> Commands.preview conf verbosity' rules p + Rebuild _ -> Commands.rebuild conf verbosity' rules + Server _ _ -> Commands.server conf (port args') -------------------------------------------------------------------------------- |