Revert "ALlow multiple comma-separated files for --defaults."

This reverts commit e96f3fd813.
This commit is contained in:
John MacFarlane 2019-11-01 21:48:30 -07:00
parent e96f3fd813
commit 02c579ff3c
2 changed files with 8 additions and 10 deletions

View file

@ -356,12 +356,11 @@ header when requesting a document from a URL:
`slidy`, `slideous`, or `s5` directory `slidy`, `slideous`, or `s5` directory
placed in this directory will override pandoc's normal defaults. placed in this directory will override pandoc's normal defaults.
`-d` *FILE*[,*FILE*,...], `--defaults=`*FILE*[,*FILE*,...] `-d` *FILE*, `--defaults=`*FILE*
: Specify a set of default option settings. *FILE* is a YAML : Specify a set of default option settings. *FILE* is a YAML
file whose fields correspond to command-line option file whose fields correspond to command-line option
settings. (Multiple files may be specified, separated by settings. All options for document conversion, including input
commas.) All options for document conversion, including input
and output files, can be set using a defaults file. The file will and output files, can be set using a defaults file. The file will
be searched for first in the working directory, and then in be searched for first in the working directory, and then in
the `defaults` subdirectory of the user data directory the `defaults` subdirectory of the user data directory

View file

@ -64,7 +64,6 @@ import Data.Text (Text)
import Text.DocTemplates (ToContext(toVal), Context(..)) import Text.DocTemplates (ToContext(toVal), Context(..))
import qualified Text.Pandoc.UTF8 as UTF8 import qualified Text.Pandoc.UTF8 as UTF8
import qualified Data.YAML as Y import qualified Data.YAML as Y
import Data.List.Split (splitWhen)
parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
parseOptions options' defaults = do parseOptions options' defaults = do
@ -162,8 +161,11 @@ options =
, Option "d" ["defaults"] , Option "d" ["defaults"]
(ReqArg (ReqArg
(\arg opt -> (\arg opt -> do
foldM applyDefaults opt (splitWhen (==',') arg) let fp' = if null (takeExtension arg)
then addExtension arg "yaml"
else arg
foldM applyDefaults opt [fp']
) )
"FILE") "FILE")
"" ""
@ -980,10 +982,7 @@ splitField s =
-- | Apply defaults from --defaults file. -- | Apply defaults from --defaults file.
applyDefaults :: Opt -> FilePath -> IO Opt applyDefaults :: Opt -> FilePath -> IO Opt
applyDefaults opt filepath = runIOorExplode $ do applyDefaults opt fp = runIOorExplode $ do
let fp = if null (takeExtension filepath)
then addExtension filepath "yaml"
else filepath
setVerbosity $ optVerbosity opt setVerbosity $ optVerbosity opt
dataDirs <- liftIO defaultUserDataDirs dataDirs <- liftIO defaultUserDataDirs
let fps = case optDataDir opt of let fps = case optDataDir opt of