aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2022-09-29 14:09:48 +0200
committerJohn MacFarlane <[email protected]>2022-09-30 08:33:40 -0700
commit0ab014ed1e5890e338792fab98aecc45cd889f99 (patch)
tree7b89e14ed2af8f31e4fac51719550d72239095c7 /src/Text
parent78814f27e07e2b9953ac1aba7f9646c3dca15a13 (diff)
[API Change] App: parameterize `options` over the scripting engine
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/App/CommandLineOptions.hs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs
index 8d5677b82..abd7703a4 100644
--- a/src/Text/Pandoc/App/CommandLineOptions.hs
+++ b/src/Text/Pandoc/App/CommandLineOptions.hs
@@ -53,6 +53,7 @@ import Text.Pandoc.App.Opt (Opt (..), LineEnding (..), IpynbOutput (..),
fullDefaultsPath)
import Text.Pandoc.Filter (Filter (..))
import Text.Pandoc.Highlighting (highlightingStyles, lookupHighlightingStyle)
+import Text.Pandoc.Scripting (ScriptingEngine (engineName))
import Text.Pandoc.Shared (ordNub, elemText, safeStrRead, defaultUserDataDir)
import Text.Printf
@@ -145,8 +146,8 @@ pdfEngines = ordNub $ map snd engines
-- | A list of functions, each transforming the options data structure
-- in response to a command-line option.
-options :: [OptDescr (Opt -> IO Opt)]
-options =
+options :: ScriptingEngine -> [OptDescr (Opt -> IO Opt)]
+options scriptingEngine =
[ Option "fr" ["from","read"]
(ReqArg
(\arg opt -> return opt { optFrom =
@@ -828,7 +829,8 @@ options =
let optnames (Option shorts longs _ _) =
map (\c -> ['-',c]) shorts ++
map ("--" ++) longs
- let allopts = unwords (concatMap optnames options)
+ let allopts = unwords (concatMap optnames
+ (options scriptingEngine))
UTF8.hPutStrLn stdout $ T.pack $ printf tpl allopts
(T.unpack $ T.unwords readersNames)
(T.unpack $ T.unwords writersNames)
@@ -960,14 +962,11 @@ options =
(\_ -> do
prg <- getProgName
defaultDatadir <- defaultUserDataDir
- luaVersion <- HsLua.run @HsLua.Exception $ do
- openlibs
- getglobal "_VERSION"
- peek top
UTF8.hPutStrLn stdout
$ T.pack
$ prg ++ " " ++ T.unpack pandocVersionText ++ versionSuffix ++
- compileInfo ++ "\nScripting engine: " ++ luaVersion ++
+ compileInfo ++ "\nScripting engine: " ++
+ T.unpack (engineName scriptingEngine) ++
"\nUser data directory: " ++ defaultDatadir ++
('\n':copyrightMessage)
exitSuccess ))
@@ -977,7 +976,8 @@ options =
(NoArg
(\_ -> do
prg <- getProgName
- UTF8.hPutStr stdout (T.pack $ usageMessage prg options)
+ UTF8.hPutStr stdout (T.pack $ usageMessage prg
+ (options scriptingEngine))
exitSuccess ))
"" -- "Show help"
]