on master help sign in
Remove verbosity from configuration
commit24273d034850b1312c551f6ace7f0b549728cbc9 authorJasper Van der Jeugt <m@jaspervdj.be> dateMon 31 Dec 2012, 15:16 (14 years ago) parented03544
7 files changed+37−48
src/Hakyll/Check.hs+7−7 src/Hakyll/Commands.hs+15−13 src/Hakyll/Core/Configuration.hs+1−9 src/Hakyll/Core/Runtime.hs+4−4 src/Hakyll/Main.hs+8−13 tests/Hakyll/Core/Runtime/Tests.hs+2−1 tests/TestSuite/Util.hs−1
src/Hakyll/Check.hs+7−7
@@ -30,16 +30,16 @@ import qualified Text.HTML.TagSoup as TS
3030
3131--------------------------------------------------------------------------------
3232import Hakyll.Core.Configuration
33−import Hakyll.Core.Logger (Logger)
33+import Hakyll.Core.Logger (Logger, Verbosity)
3434import qualified Hakyll.Core.Logger as Logger
3535import Hakyll.Core.Util.File
3636import Hakyll.Web.Html
3737
3838
3939--------------------------------------------------------------------------------
40−check :: Configuration -> IO ExitCode
41−check config = do
42− ((), write) <- runChecker checkDestination config
40+check :: Configuration -> Verbosity -> IO ExitCode
41+check config verbosity = do
42+ ((), write) <- runChecker checkDestination config verbosity
4343 return $ if checkerFaulty write >= 0 then ExitFailure 1 else ExitSuccess
4444
4545
@@ -73,9 +73,9 @@ type Checker a = RWST CheckerRead CheckerWrite CheckerState IO a
7373
7474
7575--------------------------------------------------------------------------------
76−runChecker :: Checker a -> Configuration -> IO (a, CheckerWrite)
77−runChecker checker config = do
78− logger <- Logger.new (verbosity config)
76+runChecker :: Checker a -> Configuration -> Verbosity -> IO (a, CheckerWrite)
77+runChecker checker config verbosity = do
78+ logger <- Logger.new verbosity
7979 let read' = CheckerRead config logger
8080 (x, _, write) <- runRWST checker read' S.empty
8181 Logger.flush logger
src/Hakyll/Commands.hs+15−13
@@ -23,13 +23,13 @@ import System.Process (system)
2323--------------------------------------------------------------------------------
2424import qualified Hakyll.Check as Check
2525import Hakyll.Core.Configuration
26+import Hakyll.Core.Logger (Verbosity)
2627import Hakyll.Core.Rules
2728import Hakyll.Core.Runtime
2829
2930
3031--------------------------------------------------------------------------------
3132#ifdef PREVIEW_SERVER
32−import Control.Applicative ((<$>))
3333import Control.Concurrent (forkIO)
3434import qualified Data.Set as S
3535import Hakyll.Core.Identifier
@@ -41,16 +41,16 @@ import Hakyll.Preview.Server
4141
4242--------------------------------------------------------------------------------
4343-- | Build the site
44−build :: Configuration -> Rules a -> IO ()
45−build conf rules = do
46− _ <- run conf rules
44+build :: Configuration -> Verbosity -> Rules a -> IO ()
45+build conf verbosity rules = do
46+ _ <- run conf verbosity rules
4747 return ()
4848
4949
5050--------------------------------------------------------------------------------
5151-- | Run the checker and exit
52−check :: Configuration -> IO ()
53−check config = Check.check config >>= exitWith
52+check :: Configuration -> Verbosity -> IO ()
53+check config verbosity = Check.check config verbosity >>= exitWith
5454
5555
5656--------------------------------------------------------------------------------
@@ -68,27 +68,29 @@ clean conf = do
6868
6969--------------------------------------------------------------------------------
7070-- | Preview the site
71−preview :: Configuration -> Rules a -> Int -> IO ()
71+preview :: Configuration -> Verbosity -> Rules a -> Int -> IO ()
7272#ifdef PREVIEW_SERVER
73−preview conf rules port = do
73+preview conf verbosity rules port = do
7474 -- Fork a thread polling for changes
7575 _ <- forkIO $ previewPoll conf update
7676
7777 -- Run the server in the main thread
7878 server conf port
7979 where
80− update = map toFilePath . S.toList . rulesResources <$> run conf rules
80+ update = do
81+ ruleSet <- run conf verbosity rules
82+ return $ map toFilePath $ S.toList $ rulesResources ruleSet
8183#else
82−preview _ _ _ = previewServerDisabled
84+preview _ _ _ _ = previewServerDisabled
8385#endif
8486
8587
8688--------------------------------------------------------------------------------
8789-- | Rebuild the site
88−rebuild :: Configuration -> Rules a -> IO ()
89−rebuild conf rules = do
90+rebuild :: Configuration -> Verbosity -> Rules a -> IO ()
91+rebuild conf verbosity rules = do
9092 clean conf
91− build conf rules
93+ build conf verbosity rules
9294
9395
9496--------------------------------------------------------------------------------
src/Hakyll/Core/Configuration.hs+1−9
@@ -1,8 +1,7 @@
11--------------------------------------------------------------------------------
22-- | Exports a datastructure for the top-level hakyll configuration
33module Hakyll.Core.Configuration
4− ( Verbosity (..)
5− , Configuration (..)
4+ ( Configuration (..)
65 , shouldIgnoreFile
76 , defaultConfiguration
87 ) where
@@ -13,10 +12,6 @@ import Data.List (isPrefixOf, isSuffixOf)
1312import System.FilePath (normalise, takeFileName)
1413
1514
16−--------------------------------------------------------------------------------
17−import Hakyll.Core.Logger
18−
19−
2015--------------------------------------------------------------------------------
2116data Configuration = Configuration
2217 { -- | Directory in which the output written
@@ -57,8 +52,6 @@ data Configuration = Configuration
5752 , -- | Use an in-memory cache for items. This is faster but uses more
5853 -- memory.
5954 inMemoryCache :: Bool
60− -- | Verbosity for the logger. Can be overwritten by the command-line.
61− , verbosity :: Verbosity
6255 }
6356
6457
@@ -72,7 +65,6 @@ defaultConfiguration = Configuration
7265 , ignoreFile = ignoreFile'
7366 , deployCommand = "echo 'No deploy command specified'"
7467 , inMemoryCache = True
75− , verbosity = Message
7668 }
7769 where
7870 ignoreFile' path
src/Hakyll/Core/Runtime.hs+4−4
@@ -28,7 +28,7 @@ import Hakyll.Core.Configuration
2828import Hakyll.Core.Dependencies
2929import Hakyll.Core.Identifier
3030import Hakyll.Core.Item.SomeItem
31−import Hakyll.Core.Logger (Logger)
31+import Hakyll.Core.Logger (Logger, Verbosity)
3232import qualified Hakyll.Core.Logger as Logger
3333import Hakyll.Core.Provider
3434import Hakyll.Core.Routes
@@ -41,10 +41,10 @@ import Hakyll.Core.Writable
4141
4242--------------------------------------------------------------------------------
4343-- | TODO Make this return exit code?
44−run :: Configuration -> Rules a -> IO RuleSet
45−run config rules = do
44+run :: Configuration -> Verbosity -> Rules a -> IO RuleSet
45+run config verbosity rules = do
4646 -- Initialization
47− logger <- Logger.new (verbosity config)
47+ logger <- Logger.new verbosity
4848 Logger.header logger "Initialising..."
4949 Logger.message logger "Creating store..."
5050 store <- Store.new (inMemoryCache config) $ storeDirectory config
src/Hakyll/Main.hs+8−13
@@ -35,21 +35,16 @@ hakyllWith :: Config.Configuration -> Rules a -> IO ()
3535hakyllWith conf rules = do
3636 args' <- cmdArgs hakyllArgs
3737
38− -- Overwrite conf based on args
39− let conf' = conf
40− { Config.verbosity =
41− if verbose args' then Logger.Debug else Config.verbosity conf
42− }
43−
38+ let verbosity' = if verbose args' then Logger.Debug else Logger.Message
4439 case args' of
45− Build _ -> Commands.build conf' rules
46− Check _ -> Commands.check conf'
47− Clean _ -> Commands.clean conf'
48− Deploy _ -> Commands.deploy conf'
40+ Build _ -> Commands.build conf verbosity' rules
41+ Check _ -> Commands.check conf verbosity'
42+ Clean _ -> Commands.clean conf
43+ Deploy _ -> Commands.deploy conf
4944 Help _ -> showHelp
50− Preview _ p -> Commands.preview conf' rules p
51− Rebuild _ -> Commands.rebuild conf' rules
52− Server _ _ -> Commands.server conf' (port args')
45+ Preview _ p -> Commands.preview conf verbosity' rules p
46+ Rebuild _ -> Commands.rebuild conf verbosity' rules
47+ Server _ _ -> Commands.server conf (port args')
5348
5449
5550--------------------------------------------------------------------------------
tests/Hakyll/Core/Runtime/Tests.hs+2−1
@@ -13,6 +13,7 @@ import Test.HUnit (Assertion, (@?=))
1313
1414--------------------------------------------------------------------------------
1515import Hakyll
16+import qualified Hakyll.Core.Logger as Logger
1617import Hakyll.Core.Runtime
1718import TestSuite.Util
1819
@@ -25,7 +26,7 @@ tests = testGroup "Hakyll.Core.Runtime.Tests" $ fromAssertions "run" [case01]
2526--------------------------------------------------------------------------------
2627case01 :: Assertion
2728case01 = withTestConfiguration $ \config -> do
28− _ <- run config $ do
29+ _ <- run config Logger.Error $ do
2930 match "*.md" $ do
3031 route $ setExtension "html"
3132 compile $ do
tests/TestSuite/Util.hs−1
@@ -110,5 +110,4 @@ withTestConfiguration f = do
110110 { destinationDirectory = "_testsite"
111111 , storeDirectory = "_teststore"
112112 , providerDirectory = "tests/data"
113− , verbosity = Logger.Error
114113 }