aboutsummaryrefslogtreecommitdiff
path: root/Types.hs
diff options
context:
space:
mode:
authorMirek Kratochvil <miroslav.kratochvil@uni.lu>2023-06-08 14:25:32 +0200
committerMirek Kratochvil <miroslav.kratochvil@uni.lu>2023-06-08 14:25:32 +0200
commitc6d86aeed3491f88bbfdf9667882a49efc509b1d (patch)
tree6158274ec70097b366abaeafe27d35c2b2f03f59 /Types.hs
parent4c1f0f9a4e4ee68aab098a61d3749960f568ec7f (diff)
downloadreploy-c6d86aeed3491f88bbfdf9667882a49efc509b1d.tar.gz
reploy-c6d86aeed3491f88bbfdf9667882a49efc509b1d.tar.bz2
actually take args
Diffstat (limited to 'Types.hs')
-rw-r--r--Types.hs79
1 files changed, 61 insertions, 18 deletions
diff --git a/Types.hs b/Types.hs
index 8e53611..e818c63 100644
--- a/Types.hs
+++ b/Types.hs
@@ -1,4 +1,6 @@
{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE ApplicativeDo #-}
+{-# LANGUAGE RecordWildCards #-}
-- | Separated-out main types of the deployment scriptage.
module Types where
@@ -8,6 +10,7 @@ import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Yaml as Y
import Lens.Micro.TH
+import Options.Applicative
import qualified Text.Mustache as Mu
import qualified Text.Pandoc.Definition
@@ -51,23 +54,63 @@ data SiteState =
makeLenses ''SiteState
--- | Make a completely empty `SiteState` for the `Site` monad.
-emptySiteState =
- SiteState
- { _pages = M.empty
- , _redirects = M.empty
- , _htags = M.empty
- , _installs = S.empty
- , _targets = S.empty
- , _templates = M.empty
- , _outputDir = "_site"
- , _assetDir = "assets"
- , _defaultTemplate = "default.html"
- , _redirectTemplate = "redirect.html"
- , _tagTemplate = "tag.html"
- , _urlBase = "/"
- , _dumpFinalState = False
- }
-
-- | Monad for running the site generator.
type Site a = StateT SiteState IO a
+
+-- | Parser for commandline options
+siteOptions' :: Parser SiteState
+siteOptions' = do
+ _outputDir <-
+ strOption $
+ long "output" <>
+ short 'd' <>
+ help "Directory to render the site to" <> value "_site" <> showDefault
+ _assetDir <-
+ strOption $
+ long "assets" <>
+ short 'a' <>
+ help "Assets directory to be copied verbatim" <>
+ value "assets" <> showDefault
+ --TODO templates directory!
+ _defaultTemplate <-
+ strOption $
+ long "default-template" <>
+ help "Default template to use for stuff (found in templates directory)" <>
+ value "default.html" <> showDefault
+ _redirectTemplate <-
+ strOption $
+ long "redirect-template" <>
+ help "Template for making redirect pages" <>
+ value "redirect.html" <> showDefault
+ _tagTemplate <-
+ strOption $
+ long "tag-template" <>
+ help "Template for making tag-listing pages" <>
+ value "tag.html" <> showDefault
+ _urlBase <-
+ strOption $
+ long "url-base" <>
+ short 'u' <> help "Base absolute URL" <> value "/" <> showDefault
+ _dumpFinalState <-
+ switch $
+ long "dump-state" <>
+ short 'D' <>
+ help "Print out the complete internal state after the site is built"
+ pure
+ SiteState
+ { _pages = M.empty
+ , _redirects = M.empty
+ , _htags = M.empty
+ , _installs = S.empty
+ , _targets = S.empty
+ , _templates = M.empty
+ , ..
+ }
+
+-- | ParserInfo for commandline options
+siteOptions =
+ info
+ (siteOptions' <**> helper)
+ (fullDesc <>
+ progDesc "Build a R3 Cards-like site" <>
+ header "site - the R3 site builder")