diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-11-01 10:14:30 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-11-01 10:14:30 -0700 |
commit | e96f3fd813b3f8b73c3457ff6e9177e2a4a74164 (patch) | |
tree | 8a4a62edbbe5d0493626a975bc63f987b971b3d2 /src/Text/Pandoc/App | |
parent | 1b69d5ed9444de975b707ed9ef3cdd2611e05463 (diff) | |
download | pandoc-e96f3fd813b3f8b73c3457ff6e9177e2a4a74164.tar.gz |
ALlow multiple comma-separated files for `--defaults`.
Diffstat (limited to 'src/Text/Pandoc/App')
-rw-r--r-- | src/Text/Pandoc/App/CommandLineOptions.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs index 019ec9220..cf5fb51dc 100644 --- a/src/Text/Pandoc/App/CommandLineOptions.hs +++ b/src/Text/Pandoc/App/CommandLineOptions.hs @@ -64,6 +64,7 @@ import Data.Text (Text) import Text.DocTemplates (ToContext(toVal), Context(..)) import qualified Text.Pandoc.UTF8 as UTF8 import qualified Data.YAML as Y +import Data.List.Split (splitWhen) parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt parseOptions options' defaults = do @@ -161,11 +162,8 @@ options = , Option "d" ["defaults"] (ReqArg - (\arg opt -> do - let fp' = if null (takeExtension arg) - then addExtension arg "yaml" - else arg - foldM applyDefaults opt [fp'] + (\arg opt -> + foldM applyDefaults opt (splitWhen (==',') arg) ) "FILE") "" @@ -982,7 +980,10 @@ splitField s = -- | Apply defaults from --defaults file. applyDefaults :: Opt -> FilePath -> IO Opt -applyDefaults opt fp = runIOorExplode $ do +applyDefaults opt filepath = runIOorExplode $ do + let fp = if null (takeExtension filepath) + then addExtension filepath "yaml" + else filepath setVerbosity $ optVerbosity opt dataDirs <- liftIO defaultUserDataDirs let fps = case optDataDir opt of |