diff options
| author | Albert Krewinkel <[email protected]> | 2024-06-28 09:58:21 +0200 |
|---|---|---|
| committer | Albert Krewinkel <[email protected]> | 2024-06-28 10:03:14 +0200 |
| commit | 522302a97edbe2bcfea3c6f8f7017016c02c4a37 (patch) | |
| tree | d2b43b5d2a0ab4dd456c99e4a9c22f3f06ab18f3 | |
| parent | 59cc5c37251a9a180717474612d6efbd4ad90402 (diff) | |
pandoc-cli: Refer printing of version info to the Lua interpreter
The Lua interpreter no longer terminates when called with `-v` or
`--version` arguments, thus improving compatibility with the default
`lua` interpreter program.
| -rw-r--r-- | pandoc-cli/src/pandoc.hs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/pandoc-cli/src/pandoc.hs b/pandoc-cli/src/pandoc.hs index 103ba6df1..019d0aded 100644 --- a/pandoc-cli/src/pandoc.hs +++ b/pandoc-cli/src/pandoc.hs @@ -20,7 +20,6 @@ import Text.Pandoc.App ( convertWithOpts, defaultOpts, options import Text.Pandoc.Error (handleError) import System.Exit (exitSuccess) import Data.Monoid (Any(..)) -import Control.Monad (when) import PandocCLI.Lua import PandocCLI.Server import qualified Text.Pandoc.UTF8 as UTF8 @@ -52,16 +51,16 @@ main = E.handle (handleError . Left) $ do let hasVersion = getAny $ foldMap (\s -> Any (s == "-v" || s == "--version")) (takeWhile (/= "--") rawArgs) - when hasVersion versionInfo + let versionOr action = if hasVersion then versionInfo else action case prg of - "pandoc-server.cgi" -> runCGI - "pandoc-server" -> runServer rawArgs + "pandoc-server.cgi" -> versionOr runCGI + "pandoc-server" -> versionOr $ runServer rawArgs "pandoc-lua" -> runLuaInterpreter prg rawArgs _ -> case rawArgs of "lua" : args -> runLuaInterpreter "pandoc lua" args - "server": args -> runServer args - args -> do + "server": args -> versionOr $ runServer args + args -> versionOr $ do engine <- getEngine res <- parseOptionsFromArgs options defaultOpts prg args case res of |
