diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2023-06-08 20:54:07 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2023-06-08 20:54:07 +0200 |
| commit | 2b68087b231940ad47e3e2f1a465a66c6c655f22 (patch) | |
| tree | 70c2e1c1dbf0ed05a4c641f7c53eb9929f99a757 | |
| parent | 3d805c5d8042f5b2d6b86904863bb40b54bd311f (diff) | |
| download | reploy-2b68087b231940ad47e3e2f1a465a66c6c655f22.tar.gz reploy-2b68087b231940ad47e3e2f1a465a66c6c655f22.tar.bz2 | |
source multiple directories at once
| -rw-r--r-- | Types.hs | 11 | ||||
| -rw-r--r-- | site.hs | 4 |
2 files changed, 8 insertions, 7 deletions
@@ -6,6 +6,7 @@ module Types where import Control.Monad.Trans.State.Lazy +import Data.List.NonEmpty import qualified Data.Map as M import qualified Data.Set as S import qualified Data.Yaml as Y @@ -44,7 +45,7 @@ data SiteState = , _templates :: M.Map FilePath Mu.Template , _outputDir :: FilePath -- ^ Directory for output , _assetDir :: FilePath -- ^ Directory for output - , _sourceDir :: FilePath -- ^ Path to page source data + , _sourceDirs :: [FilePath] -- ^ Path to page source data , _templateDir :: FilePath -- ^ Path to template directory , _defaultTemplate :: FilePath -- ^ Name of the default template , _redirectTemplate :: FilePath -- ^ Name of the template for redirect pages @@ -73,12 +74,12 @@ siteOptions' = do short 'a' <> help "Assets directory to be copied verbatim" <> value "assets" <> showDefault - _sourceDir <- - strOption $ + _sourceDirs <- + fmap (maybe ["cards"] toList . nonEmpty) . many . strOption $ long "source-directory" <> short 's' <> - help "Path to the directory with source data (possibly multiple paths)" <> - value "cards" <> showDefault + help + "Path to the directory with source data (possibly multiple paths, defaults to a single directory \"cards\")" _templateDir <- strOption $ long "template-directory" <> @@ -127,7 +127,7 @@ checkTarget fp = do -- | Prepend the root path to the given link rootUrl :: FilePath -> Site FilePath -rootUrl fp = (</> dropWhile (=='/') fp) <$> use urlBase +rootUrl fp = (</> dropWhile (== '/') fp) <$> use urlBase -- | Process a single link pointing out from a page. processLink :: FilePath -> FilePath -> Site String @@ -324,7 +324,7 @@ main = do init <- Options.Applicative.execParser siteOptions flip runStateT init $ do installAssets - use sourceDir >>= sourcePages + use sourceDirs >>= traverse sourcePages sourceTags use templateDir >>= sourceTemplates use pages >>= traverse (uncurry installPage) . M.assocs |
