@@ -118,34 +118,7 @@ findFile (f:fs) = do
118-- in response to a command-line option.
118-- in response to a command-line option.
119options :: [OptDescr (Opt -> IO Opt)]
119options :: [OptDescr (Opt -> IO Opt)]
121− [ Option "" ["defaults"]
123− (\arg opt -> runIOorExplode $ do
124− setVerbosity $ optVerbosity opt
125− let fp = if null (takeExtension arg)
126− then addExtension arg "yaml"
128− dataDirs <- liftIO defaultUserDataDirs
129− let fps = case optDataDir opt of
130− Nothing -> (fp : map (</> ("defaults" </> fp))
132− Just dd -> [fp, dd </> "defaults" </> fp]
133− fp' <- fromMaybe fp <$> findFile fps
134− inp <- readFileLazy fp'
135− let defaults = YA.encode1 opt
136− case YA.decode1 (defaults <> inp) of
137− Right (newopts :: Opt) -> return newopts
138− Left (errpos, errmsg) -> throwError $
140− "Error parsing " ++ fp' ++
141− " (line " ++ show (Y.posLine errpos) ++
142− " column " ++ show (Y.posColumn errpos) ++
148− , Option "fr" ["from","read"]
121+ [ Option "fr" ["from","read"]
150 (\arg opt -> return opt { optFrom =
123 (\arg opt -> return opt { optFrom =
151 Just (map toLower arg) })
124 Just (map toLower arg) })
@@ -165,31 +138,6 @@ options =
166 "" -- "Name of output file"
139 "" -- "Name of output file"
168− , Option "" ["wrap"]
172− "auto" -> return opt{ optWrapText = WrapAuto }
173− "none" -> return opt{ optWrapText = WrapNone }
174− "preserve" -> return opt{ optWrapText = WrapPreserve }
175− _ -> E.throwIO $ PandocOptionError
176− "--wrap must be auto, none, or preserve")
177− "auto|none|preserve")
178− "" -- "Option for wrapping text in output"
180− , Option "s" ["standalone"]
182− (\opt -> return opt { optStandalone = True }))
183− "" -- "Include needed header and footer on output"
185− , Option "" ["template"]
188− return opt{ optTemplate = Just (normalizePath arg),
189− optStandalone = True })
191− "" -- "Use custom template"
193 , Option "" ["data-dir"]
141 , Option "" ["data-dir"]
195 (\arg opt -> return opt { optDataDir =
143 (\arg opt -> return opt { optDataDir =
@@ -213,6 +161,51 @@ options =
164+ , Option "" ["defaults"]
166+ (\arg opt -> runIOorExplode $ do
167+ setVerbosity $ optVerbosity opt
168+ let fp = if null (takeExtension arg)
169+ then addExtension arg "yaml"
171+ dataDirs <- liftIO defaultUserDataDirs
172+ let fps = case optDataDir opt of
173+ Nothing -> (fp : map (</> ("defaults" </> fp))
175+ Just dd -> [fp, dd </> "defaults" </> fp]
176+ fp' <- fromMaybe fp <$> findFile fps
177+ inp <- readFileLazy fp'
178+ let defaults = YA.encode1 opt
179+ case YA.decode1 (defaults <> inp) of
180+ Right (newopts :: Opt) -> return newopts
181+ Left (errpos, errmsg) -> throwError $
183+ "Error parsing " ++ fp' ++
184+ " (line " ++ show (Y.posLine errpos) ++
185+ " column " ++ show (Y.posColumn errpos) ++
191+ , Option "" ["file-scope"]
193+ (\opt -> return opt { optFileScope = True }))
194+ "" -- "Parse input files before combining"
196+ , Option "s" ["standalone"]
198+ (\opt -> return opt { optStandalone = True }))
199+ "" -- "Include needed header and footer on output"
201+ , Option "" ["template"]
204+ return opt{ optTemplate = Just (normalizePath arg),
205+ optStandalone = True })
207+ "" -- "Use custom template"
216 , Option "V" ["variable"]
209 , Option "V" ["variable"]
218 (\arg opt -> do
211 (\arg opt -> do
@@ -222,6 +215,18 @@ options =
222 "KEY[:VALUE]")
215 "KEY[:VALUE]")
218+ , Option "" ["wrap"]
222+ "auto" -> return opt{ optWrapText = WrapAuto }
223+ "none" -> return opt{ optWrapText = WrapNone }
224+ "preserve" -> return opt{ optWrapText = WrapPreserve }
225+ _ -> E.throwIO $ PandocOptionError
226+ "--wrap must be auto, none, or preserve")
227+ "auto|none|preserve")
228+ "" -- "Option for wrapping text in output"
225 , Option "" ["ascii"]
230 , Option "" ["ascii"]
227 (\opt -> return opt { optAscii = True }))
232 (\opt -> return opt { optAscii = True }))
@@ -431,11 +436,6 @@ options =
431 "NAME:VALUE")
436 "NAME:VALUE")
434− , Option "" ["file-scope"]
436− (\opt -> return opt { optFileScope = True }))
437− "" -- "Parse input files before combining"
439 , Option "" ["abbreviations"]
439 , Option "" ["abbreviations"]
441 (\arg opt -> return opt { optAbbreviations = Just arg })
441 (\arg opt -> return opt { optAbbreviations = Just arg })