summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-02-06 14:52:16 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-02-06 14:52:16 +0100
commit37e579581a1ba02daede294474d97127124fdf17 (patch)
tree682189557967fa74d0978dae81d94ecc467b40f8
parent67dc15771d5ae89ff691adae0e1b1f8f7590182b (diff)
Consolidated file arguments into Opt.
-rw-r--r--pandoc.hs4
-rw-r--r--src/Text/Pandoc/App.hs11
2 files changed, 8 insertions, 7 deletions
diff --git a/pandoc.hs b/pandoc.hs
index 4a57b7f50..298161249 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -33,7 +33,5 @@ module Main where
import Text.Pandoc.App (defaultOpts, convertWithOpts, parseOptions, options)
main :: IO ()
-main = do
- (opts, args) <- parseOptions options defaultOpts
- convertWithOpts opts args
+main = parseOptions options defaultOpts >>= convertWithOpts
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index a56ee2427..53ad1325b 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -82,7 +82,7 @@ import System.Posix.Terminal (queryTerminal)
import System.Posix.IO (stdOutput)
#endif
-parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO (Opt, [FilePath])
+parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
parseOptions options' defaults = do
rawArgs <- map UTF8.decodeArg <$> getArgs
prg <- getProgName
@@ -98,10 +98,11 @@ parseOptions options' defaults = do
-- thread option data structure through all supplied option actions
opts <- foldl (>>=) (return defaults) actions
- return (opts, args)
+ return (opts{ optInputFiles = args })
-convertWithOpts :: Opt -> [FilePath] -> IO ()
-convertWithOpts opts args = do
+convertWithOpts :: Opt -> IO ()
+convertWithOpts opts = do
+ let args = optInputFiles opts
let outputFile = optOutputFile opts
let filters = optFilters opts
let verbosity = optVerbosity opts
@@ -469,6 +470,7 @@ data Opt = Opt
, optVariables :: [(String,String)] -- ^ Template variables to set
, optMetadata :: [(String, String)] -- ^ Metadata fields to set
, optOutputFile :: FilePath -- ^ Name of output file
+ , optInputFiles :: [FilePath] -- ^ Names of input files
, optNumberSections :: Bool -- ^ Number sections in LaTeX
, optNumberOffset :: [Int] -- ^ Starting number for sections
, optSectionDivs :: Bool -- ^ Put sections in div tags in HTML
@@ -534,6 +536,7 @@ defaultOpts = Opt
, optVariables = []
, optMetadata = []
, optOutputFile = "-" -- "-" means stdout
+ , optInputFiles = []
, optNumberSections = False
, optNumberOffset = [0,0,0,0,0,0]
, optSectionDivs = False