Merge pull request #178 from blaenk/port-option
add preview port Configuration field
This commit is contained in:
commit
11d5b8064a
2 changed files with 13 additions and 7 deletions
|
@ -69,6 +69,10 @@ data Configuration = Configuration
|
||||||
, -- | Use an in-memory cache for items. This is faster but uses more
|
, -- | Use an in-memory cache for items. This is faster but uses more
|
||||||
-- memory.
|
-- memory.
|
||||||
inMemoryCache :: Bool
|
inMemoryCache :: Bool
|
||||||
|
, -- | Override default port for preview server. Default is 8000.
|
||||||
|
-- One can also override the port as a command line argument:
|
||||||
|
-- ./site preview -p 1234
|
||||||
|
previewPort :: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -87,6 +91,7 @@ defaultConfiguration = Configuration
|
||||||
, deployCommand = "echo 'No deploy command specified' && exit 1"
|
, deployCommand = "echo 'No deploy command specified' && exit 1"
|
||||||
, deploySite = system . deployCommand
|
, deploySite = system . deployCommand
|
||||||
, inMemoryCache = True
|
, inMemoryCache = True
|
||||||
|
, previewPort = 8000
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
ignoreFile' path
|
ignoreFile' path
|
||||||
|
|
|
@ -34,7 +34,7 @@ hakyll = hakyllWith Config.defaultConfiguration
|
||||||
-- configuration
|
-- configuration
|
||||||
hakyllWith :: Config.Configuration -> Rules a -> IO ()
|
hakyllWith :: Config.Configuration -> Rules a -> IO ()
|
||||||
hakyllWith conf rules = do
|
hakyllWith conf rules = do
|
||||||
args' <- cmdArgs hakyllArgs
|
args' <- cmdArgs (hakyllArgs conf)
|
||||||
|
|
||||||
let verbosity' = if verbose args' then Logger.Debug else Logger.Message
|
let verbosity' = if verbose args' then Logger.Debug else Logger.Message
|
||||||
check' =
|
check' =
|
||||||
|
@ -55,7 +55,7 @@ hakyllWith conf rules = do
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- | Show usage information.
|
-- | Show usage information.
|
||||||
showHelp :: IO ()
|
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 :: Config.Configuration -> HakyllArgs
|
||||||
hakyllArgs = modes
|
hakyllArgs conf = modes
|
||||||
[ (Build $ verboseFlag def) &= help "Generate the site"
|
[ (Build $ verboseFlag def) &= help "Generate the site"
|
||||||
, (Check (verboseFlag def) (False &= help "Check internal links only")) &=
|
, (Check (verboseFlag def) (False &= help "Check internal links only")) &=
|
||||||
help "Validate the site output"
|
help "Validate the site output"
|
||||||
, (Clean $ verboseFlag def) &= help "Clean up and remove cache"
|
, (Clean $ verboseFlag def) &= help "Clean up and remove cache"
|
||||||
, (Deploy $ verboseFlag def) &= help "Upload/deploy your site"
|
, (Deploy $ verboseFlag def) &= help "Upload/deploy your site"
|
||||||
, (Help $ verboseFlag def) &= help "Show this message" &= auto
|
, (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"
|
help "[Deprecated] Please use the watch command"
|
||||||
, (Rebuild $ verboseFlag def) &= help "Clean and build again"
|
, (Rebuild $ verboseFlag def) &= help "Clean and build again"
|
||||||
, (Server (verboseFlag def) (portFlag 8000)) &=
|
, (Server (verboseFlag def) (portFlag defaultPort)) &=
|
||||||
help "Start a preview server"
|
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 "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
|
] &= help "Hakyll static site compiler" &= program progName
|
||||||
|
where defaultPort = Config.previewPort conf
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue