diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/App/CommandLineOptions.hs | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs index a7b20a6e3..bbbbbeb7c 100644 --- a/src/Text/Pandoc/App/CommandLineOptions.hs +++ b/src/Text/Pandoc/App/CommandLineOptions.hs @@ -118,34 +118,7 @@ findFile (f:fs) = do -- in response to a command-line option. options :: [OptDescr (Opt -> IO Opt)] options = - [ Option "" ["defaults"] - (ReqArg - (\arg opt -> runIOorExplode $ do - setVerbosity $ optVerbosity opt - let fp = if null (takeExtension arg) - then addExtension arg "yaml" - else arg - dataDirs <- liftIO defaultUserDataDirs - let fps = case optDataDir opt of - Nothing -> (fp : map (</> ("defaults" </> fp)) - dataDirs) - Just dd -> [fp, dd </> "defaults" </> fp] - fp' <- fromMaybe fp <$> findFile fps - inp <- readFileLazy fp' - let defaults = YA.encode1 opt - case YA.decode1 (defaults <> inp) of - Right (newopts :: Opt) -> return newopts - Left (errpos, errmsg) -> throwError $ - PandocParseError $ - "Error parsing " ++ fp' ++ - " (line " ++ show (Y.posLine errpos) ++ - " column " ++ show (Y.posColumn errpos) ++ - ")\n" ++ errmsg - ) - "FILE") - "" - - , Option "fr" ["from","read"] + [ Option "fr" ["from","read"] (ReqArg (\arg opt -> return opt { optFrom = Just (map toLower arg) }) @@ -165,31 +138,6 @@ options = "FILE") "" -- "Name of output file" - , Option "" ["wrap"] - (ReqArg - (\arg opt -> - case arg of - "auto" -> return opt{ optWrapText = WrapAuto } - "none" -> return opt{ optWrapText = WrapNone } - "preserve" -> return opt{ optWrapText = WrapPreserve } - _ -> E.throwIO $ PandocOptionError - "--wrap must be auto, none, or preserve") - "auto|none|preserve") - "" -- "Option for wrapping text in output" - - , Option "s" ["standalone"] - (NoArg - (\opt -> return opt { optStandalone = True })) - "" -- "Include needed header and footer on output" - - , Option "" ["template"] - (ReqArg - (\arg opt -> - return opt{ optTemplate = Just (normalizePath arg), - optStandalone = True }) - "FILE") - "" -- "Use custom template" - , Option "" ["data-dir"] (ReqArg (\arg opt -> return opt { optDataDir = @@ -213,6 +161,51 @@ options = "FILE") "" + , Option "" ["defaults"] + (ReqArg + (\arg opt -> runIOorExplode $ do + setVerbosity $ optVerbosity opt + let fp = if null (takeExtension arg) + then addExtension arg "yaml" + else arg + dataDirs <- liftIO defaultUserDataDirs + let fps = case optDataDir opt of + Nothing -> (fp : map (</> ("defaults" </> fp)) + dataDirs) + Just dd -> [fp, dd </> "defaults" </> fp] + fp' <- fromMaybe fp <$> findFile fps + inp <- readFileLazy fp' + let defaults = YA.encode1 opt + case YA.decode1 (defaults <> inp) of + Right (newopts :: Opt) -> return newopts + Left (errpos, errmsg) -> throwError $ + PandocParseError $ + "Error parsing " ++ fp' ++ + " (line " ++ show (Y.posLine errpos) ++ + " column " ++ show (Y.posColumn errpos) ++ + ")\n" ++ errmsg + ) + "FILE") + "" + + , Option "" ["file-scope"] + (NoArg + (\opt -> return opt { optFileScope = True })) + "" -- "Parse input files before combining" + + , Option "s" ["standalone"] + (NoArg + (\opt -> return opt { optStandalone = True })) + "" -- "Include needed header and footer on output" + + , Option "" ["template"] + (ReqArg + (\arg opt -> + return opt{ optTemplate = Just (normalizePath arg), + optStandalone = True }) + "FILE") + "" -- "Use custom template" + , Option "V" ["variable"] (ReqArg (\arg opt -> do @@ -222,6 +215,18 @@ options = "KEY[:VALUE]") "" + , Option "" ["wrap"] + (ReqArg + (\arg opt -> + case arg of + "auto" -> return opt{ optWrapText = WrapAuto } + "none" -> return opt{ optWrapText = WrapNone } + "preserve" -> return opt{ optWrapText = WrapPreserve } + _ -> E.throwIO $ PandocOptionError + "--wrap must be auto, none, or preserve") + "auto|none|preserve") + "" -- "Option for wrapping text in output" + , Option "" ["ascii"] (NoArg (\opt -> return opt { optAscii = True })) @@ -431,11 +436,6 @@ options = "NAME:VALUE") "" - , Option "" ["file-scope"] - (NoArg - (\opt -> return opt { optFileScope = True })) - "" -- "Parse input files before combining" - , Option "" ["abbreviations"] (ReqArg (\arg opt -> return opt { optAbbreviations = Just arg }) |