summaryrefslogtreecommitdiff
path: root/src/Hakyll/Main.hs
diff options
context:
space:
mode:
authorJorge Israel Peña <jorgepblank@gmail.com>2013-08-29 22:43:57 -0700
committerJorge Israel Peña <jorgepblank@gmail.com>2013-08-29 22:43:57 -0700
commit999252ece13cd695d65fed9cd01960f5ef3c60ff (patch)
treec2e15b4493daeb808742da6ce19319f1383ede47 /src/Hakyll/Main.hs
parent94d7281a2c4f21e67e2da09c6029cf60583c37e7 (diff)
downloadhakyll-999252ece13cd695d65fed9cd01960f5ef3c60ff.tar.gz
add preview port Configuration field
Make it possible to specify the default port to listen on when the preview server is run. This is useful if another service on the system already runs on port 8000 (the default), since it's a hassle to keep providing the port overriding option. For example: ./site preview vs. ./site preview -p 4000
Diffstat (limited to 'src/Hakyll/Main.hs')
-rw-r--r--src/Hakyll/Main.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Hakyll/Main.hs b/src/Hakyll/Main.hs
index 4b30939..86516cb 100644
--- a/src/Hakyll/Main.hs
+++ b/src/Hakyll/Main.hs
@@ -34,7 +34,7 @@ hakyll = hakyllWith Config.defaultConfiguration
-- configuration
hakyllWith :: Config.Configuration -> Rules a -> IO ()
hakyllWith conf rules = do
- args' <- cmdArgs hakyllArgs
+ args' <- cmdArgs (hakyllArgs conf)
let verbosity' = if verbose args' then Logger.Debug else Logger.Message
check' =
@@ -55,7 +55,7 @@ hakyllWith conf rules = do
--------------------------------------------------------------------------------
-- | Show usage information.
showHelp :: IO ()
-showHelp = print $ CA.helpText [] CA.HelpFormatOne $ cmdArgsMode hakyllArgs
+showHelp = print $ CA.helpText [] CA.HelpFormatOne $ cmdArgsMode (hakyllArgs Config.defaultConfiguration)
--------------------------------------------------------------------------------
@@ -73,22 +73,23 @@ data HakyllArgs
--------------------------------------------------------------------------------
-hakyllArgs :: HakyllArgs
-hakyllArgs = modes
+hakyllArgs :: Config.Configuration -> HakyllArgs
+hakyllArgs conf = modes
[ (Build $ verboseFlag def) &= help "Generate the site"
, (Check (verboseFlag def) (False &= help "Check internal links only")) &=
help "Validate the site output"
, (Clean $ verboseFlag def) &= help "Clean up and remove cache"
, (Deploy $ verboseFlag def) &= help "Upload/deploy your site"
, (Help $ verboseFlag def) &= help "Show this message" &= auto
- , (Preview (verboseFlag def) (portFlag 8000)) &=
+ , (Preview (verboseFlag def) (portFlag defaultPort)) &=
help "[Deprecated] Please use the watch command"
, (Rebuild $ verboseFlag def) &= help "Clean and build again"
- , (Server (verboseFlag def) (portFlag 8000)) &=
+ , (Server (verboseFlag def) (portFlag defaultPort)) &=
help "Start a preview server"
- , (Watch (verboseFlag def) (portFlag 8000) (noServerFlag False) &=
+ , (Watch (verboseFlag def) (portFlag defaultPort) (noServerFlag False) &=
help "Autocompile on changes and start a preview server. You can watch and recompile without running a server with --no-server.")
] &= help "Hakyll static site compiler" &= program progName
+ where defaultPort = Config.previewPort conf
--------------------------------------------------------------------------------